Skip to content

Instantly share code, notes, and snippets.

View onkar27's full-sized avatar

Onkar J. Sathe onkar27

View GitHub Profile
onkar27 / gist:ef7d441847b8c8da8dac6b7f388fff22
Created July 23, 2018 17:39 — forked from dsci/gist:1347672
Delete commits from repository.
# First, check out the commit you wish to go back to (get sha-1 from git log)
git reset --hard 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a
# Then do a forced update.
git push origin +9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a^:develop
# Push specific commit
git push origin 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a:develop -f
onkar27 / heaps.cpp
Created July 13, 2018 17:37
Heaps using C++ STL
// max heap
priority_queue <ll> max_heap; // by defualt priority_queue is maxheap always.
// min heap
priority_queue <ll, vector<ll>, greater<ll> > min_heap;
// type, container, comparator function
typedef struct mystruct {
ll one;
typedef long long ll;
inline fastRead()
register char ch=0;
while (ch<33) ch=getchar();
ll x=0;
while (ch>33)
onkar27 / gcds.cpp
Created April 1, 2018 17:31
Greatest Common Divisor + Power + Inverse Modulo
ll modularExponentiation(ll x,ll n,ll M)
ll result=1;
if(n % 2 ==1)
result=(result * x)%M;
onkar27 / nCr.cpp
Last active July 26, 2019 19:04
Iterative function to calculate power exponential and nCr implementation
ll power(ll x, ll y, ll p)
ll res = 1;
x = x % p;
while (y > 0)
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
onkar27 / pbds.cpp
Created February 1, 2018 12:59
Policy Based Data Structure
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int main(){
onkar27 / segment_rmq.cpp
Created January 21, 2018 13:09
Segment Tree Implementation for Minimum number.
#define ll long long
#define vll vector<ll>
#define sll set<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define fo(i,m,n) for(i=m;i<n;i++)
#define fore(i,m,n) for(i=m;i>=n;i--)
using namespace std;
onkar27 / Chrome_dinosaur.cpp
Created January 21, 2018 06:43
Chrome's Dinosaur Game designed in C++ "graphics.h"
//Onkar J Sathe
#include <bits/stdc++.h>
#include <graphics.h>
using namespace std;
#define Mx getmaxx()
#define My getmaxy()
#include <dos.h>
#include <windows.h>
int main()
#define X 116
#define Y 28
using namespace std;
void gotoxy(short x, short y){