Skip to content

Instantly share code, notes, and snippets.

View MuhammadJahidHasan's full-sized avatar

Muhammad Jahid Hasan MuhammadJahidHasan

View GitHub Profile
@MuhammadJahidHasan
MuhammadJahidHasan / mergeSort.js
Created November 10, 2021 12:07
MergeSort implementation in js
const merge = function(arr, l, r, m ) {
let n1 = (m - l) + 1;
let n2 = r - m;
let arr1 = new Array(n1);
let arr2 = new Array(n2);
@MuhammadJahidHasan
MuhammadJahidHasan / LinkedList.cbp
Created December 30, 2020 09:34
Linked List Implementation with c
#include <bits/stdc++.h>
using namespace std;
typedef struct node Node;
struct node{
int data;
Node *next;
@MuhammadJahidHasan
MuhammadJahidHasan / BinaryTree.cbp
Created December 30, 2020 09:32
Binary Tree Implementation with c
#include <bits/stdc++.h>
using namespace std;
typedef struct node Node;
struct node{
int data;
Node *left;
Node *right;
@MuhammadJahidHasan
MuhammadJahidHasan / BFS
Created January 26, 2019 10:25
BFS implementation and find level of a node
#include <bits/stdc++.h>
using namespace std;
vector<int>edg[100];
queue<int> q;
int vis[100];
int level[100];
@MuhammadJahidHasan
MuhammadJahidHasan / gist:9b9cdb991061571cdeed25f5ef15266d
Created October 23, 2018 10:27
How to check parity in binary number
#include<iostream>
#include <stdio.h>
# define bool int
using namespace std;
bool getParity(unsigned int n)
{
#include <iostream>
using namespace std;
int main()
{
int coin[2]={2,4};
int n;
cin>>n;
int taka[n+1];
@MuhammadJahidHasan
MuhammadJahidHasan / gist:90d57ac35caad0e2493c39bf69459f46
Created March 20, 2018 06:43
Fibonacci with dynamic program in bottom up approach
#include <iostream>
using namespace std;
long long dp[1000];
long long fib(int n){
if(n==1 || n==2) return 1;
@MuhammadJahidHasan
MuhammadJahidHasan / gist:52fad6f3bc8364bafc965341b1ac9ce3
Last active March 21, 2018 17:25
How to find level and which node is visited and path in graph(BFS)
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<int>edge[10000];
int vis[100];
int level[100];
int path[100];
@MuhammadJahidHasan
MuhammadJahidHasan / gist:efab040b8ac519e75cf31459963f128d
Created March 13, 2018 13:41
Longest common sub sequences(LCS)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string r,s1,s2;int ls1,ls2,co=0;
cin>>s1;
@MuhammadJahidHasan
MuhammadJahidHasan / gist:7212b308abbddb7afca7115b6a3208fa
Created March 5, 2018 14:40
How to represent graph list in c++
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define MAX 10000
vector <int> edges[MAX];
vector<int>cost[MAX];