Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Either Optimising or Developing something...

Abhishek Srivastava abhishek2x

💻
Either Optimising or Developing something...
View GitHub Profile
@abhishek2x
abhishek2x / union_find.cpp
Created Sep 16, 2021
Template for Union Find Algorithm used in Graph related problems.
View union_find.cpp
struct DisjointSet {
vector<int> parent;
vector<int> size;
DisjointSet(int maxSize) {
parent.resize(maxSize);
size.resize(maxSize);
for (int i = 0; i < maxSize; i++) {
parent[i] = i;
size[i] = 1;
@abhishek2x
abhishek2x / webpack.config.js
Created Feb 5, 2021
Webpack basic configuration
View webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
};
@abhishek2x
abhishek2x / 2d.cpp
Created Dec 19, 2020
Searching in 2-D Array
View 2d.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / binf.cpp
Created Dec 19, 2020
Searching in Bitonic Infinite Array.
View binf.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / inf.cpp
Created Dec 19, 2020
Finding a position on an Element in an infinite array
View inf.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int binaryPlay(vector<int> a, int l, int h, int key){
while(l<=h){
@abhishek2x
abhishek2x / near.cpp
Created Dec 19, 2020
Searching in Nearly Sorted Array
View near.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / cnt.cpp
Created Dec 19, 2020
Count how many times a Sorted array is rotated
View cnt.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int countRotations(int arr[], int low, int high)
@abhishek2x
abhishek2x / sq.cpp
Last active Dec 19, 2020
Finding Square root using Binary Search Algorithm
View sq.cpp
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
/*
For demstration of concept we are using
int variable. But ideally we will prefer using
double value with an Epison error estimation.
*/
@abhishek2x
abhishek2x / peak.cpp
Created Nov 29, 2020
Finding the peak of an array
View peak.cpp
/*!
* Finding the peak of an array
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / Ceil.cpp
Created Nov 29, 2020
Finding Ceil of an Element in a Sorted array
View Ceil.cpp
/*!
* Finding Ceil of an Element in a Sorted array
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){