Skip to content

Instantly share code, notes, and snippets.

Avatar

Ahmedur Rahman Shovon arsho

View GitHub Profile
View Solution.java
class Solution {
// Function to return Breadth First Traversal of given graph.
public ArrayList < Integer > bfsOfGraph(int V, ArrayList < ArrayList < Integer >> adj) {
ArrayList < Integer > ans = new ArrayList < Integer > ();
int[] color = new int[V];
color[0] = 1;
Queue < Integer > q = new LinkedList < > ();
q.add(0);
ans.add(0);
while (q.size() != 0) {
View Stackoverflow_Answer.md

Four numbers each from -1 to 1 that sum up to 1

You can use Python's combination with replacement method.

from itertools import combinations_with_replacement
import csv

def get_four_numbers(target_sum=100):
 result = []
View hackerearth_counting_inversions.cpp
#include <bits/stdc++.h>
using namespace std;
long merge_sorted_arrays(long ar[], long temp[], long left, long mid, long right) {
long inversion_count = 0;
long left_pos = left;
long right_pos = mid + 1;
long current_pos = left;
while (left_pos <= mid && right_pos <= right) {
if (ar[left_pos] <= ar[right_pos]) {
@arsho
arsho / fix_ethernet.md
Created Jan 18, 2021
Fixed unmanaged ethernet connection in Ubuntu 20.10
View fix_ethernet.md

Scenario

  • In Ubuntu the Ethernet connection was shown as unmanaged wired connection.
  • This happened after using sudo pppoeconf to configure a pppoeconfiguration.

Solution

  • Open /etc/NetworkManager/NetworkManager.conf with sudo previlege:
sudo gedit /etc/NetworkManager/NetworkManager.conf
  • Change the line managed=false to managed=true
@arsho
arsho / dell_logo_freeze_ubuntu.md
Created Jan 10, 2021
Solution to Ubuntu 20.04 LTS Dell logo freeze screen
View dell_logo_freeze_ubuntu.md

Solution to: Stuck on Dell logo in Dual Boot Dell Machine

Machine Information:

  • Model: Dell G5 5587
  • Processor: Intel core i7-8750H
  • Ram: 16GB
  • Graphics: NVIDIA 1060 GeForce GTX 1060 Mobile
  • SSD: 256GB
  • HDD: 1TB
@arsho
arsho / fix_nvidia_driver_ubuntu_20.04.md
Last active Nov 6, 2020
Ubuntu 20.04 Upgrade nVidia graphics card issue.
View fix_nvidia_driver_ubuntu_20.04.md

Scenario

  • Upgraded to Ubuntu 20.04 from Ubuntu 18.04
  • Previously the graphics card was shown nVidia in Ubuntu about section
  • Now its llvmpipe (LLVM 10.0.0, 256 bits) / llvmpipe (LLVM 10.0.0, 256 bits)

Solution

  • Install all necessary drivers:
sudo ubuntu-drivers autoinstall
@arsho
arsho / allocation_solution_using_counting_sort.py
Created Aug 9, 2020
Google Kick Start 2020 - Round A: Allocation (5pts, 7pts). Time complexity: O(N) for counting sort and O(NlogN) for default sort.
View allocation_solution_using_counting_sort.py
def get_sorted_values(values):
occurrences = [0] * 1001
sorted_values = [0]*len(values)
for value in values:
occurrences[value] += 1
for i in range(1, 1001):
occurrences[i] += occurrences[i-1]
for i in range(len(values)-1, -1, -1):
sorted_values[occurrences[values[i]]-1] = values[i]
occurrences[values[i]] -= 1
@arsho
arsho / dataframe.md
Last active Jul 15, 2020
Stackoverflow suggestions for new questions
View dataframe.md
View database_value.txt
"<div id=\"54d74ae1-aaa7-4169-8e43-f2c254126761\" class=\"plotly-graph-div\" style=\"height:600px; width:900px;\"></div>\n <script type=\"text/javascript\">\n$(document).ready(function(){\n window.PLOTLYENV=window.PLOTLYENV || {};\n\n if (document.getElementById(\"54d74ae1-aaa7-4169-8e43-f2c254126761\")) {\n Plotly.newPlot(\n '54d74ae1-aaa7-4169-8e43-f2c254126761',\n [{\"marker\": {\"color\": \"black\", \"size\": 4}, \"mode\": \"markers\", \"name\": \"Actual\", \"type\": \"scatter\", \"x\": [\"2020-03-18T00:00:00\", \"2020-03-19T00:00:00\", \"2020-03-20T00:00:00\", \"2020-03-21T00:00:00\", \"2020-03-22T00:00:00\", \"2020-03-23T00:00:00\", \"2020-03-24T00:00:00\", \"2020-03-25T00:00:00\", \"2020-03-26T00:00:00\", \"2020-03-27T00:00:00\", \"2020-03-28T00:00:00\", \"2020-03-29T00:00:00\", \"2020-03-30T00:00:00\", \"2020-03-31T00:00:00\", \"2020-04-01T00:00:00\", \"2020-04-02T00:00:00\", \"2020-04-03T00:00:00\", \"2020-04-04T00:00:00\", \"2020-04-05T00:00:00\", \"2020-04-06T00:00
View body_include.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.51.1/plotly.min.js" integrity="sha256-qe/oN+ddr+wOzXyDWGSx8glJYbdQk2FwExwyQgNMsdQ=" crossorigin="anonymous"></script>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<div id="54d74ae1-aaa7-4169-8e43-f2c254126761" class="plotly-graph-div" style="height:600px; width:900px;"></div>
<script type="text/javascript">
$(document).ready(function(){
<?php echo $db->variable ?>
})
</script>
<!---->