Skip to content

Instantly share code, notes, and snippets.

View abhishek2x's full-sized avatar
💻
Either Optimising or Developing something...

Abhishek Srivastava abhishek2x

💻
Either Optimising or Developing something...
View GitHub Profile
@abhishek2x
abhishek2x / union_find.cpp
Created September 16, 2021 16:14
Template for Union Find Algorithm used in Graph related problems.
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 February 5, 2021 22:31
Webpack basic configuration
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
};
@abhishek2x
abhishek2x / 2d.cpp
Created December 19, 2020 14:08
Searching in 2-D Array
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / binf.cpp
Created December 19, 2020 14:03
Searching in Bitonic Infinite Array.
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / inf.cpp
Created December 19, 2020 13:59
Finding a position on an Element in an infinite array
/*!
* 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 December 19, 2020 13:54
Searching in Nearly Sorted Array
/*!
* Copyright (c) 2020 Abhishek Srivastava
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
@abhishek2x
abhishek2x / cnt.cpp
Created December 19, 2020 13:32
Count how many times a Sorted array is rotated
/*!
* 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 December 19, 2020 13:00
Finding Square root using Binary Search Algorithm
/*!
* 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 November 29, 2020 10:43
Finding the peak of an array
/*!
* 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 November 29, 2020 10:17
Finding Ceil of an Element in a Sorted array
/*!
* Finding Ceil of an Element in a Sorted array
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){