Skip to content

Instantly share code, notes, and snippets.

Ani Mishra aaani

Block or report user

Report or block aaani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aaani / get_xhr.js
Created Aug 16, 2014
Pure javascript module to send an ajax get request. It works well on IE8+ and other modern browsers.
View get_xhr.js
var GetXHR = (function() {
var module = {};
module.sendRequest = function(url, callback) {
var req;
if (window.XDomainRequest) {
req = new XDomainRequest();
if (!req) return;
req.onload = function(){
View maxLenSubstring2Chars.cpp
pair<pair<char,char>,int> maxLenSubstring2Chars(string s){
pair<char,int> lastChar;
pair<pair<char,char>,int> longestPairYet;
pair<pair<char,char>,int> currentPair;
View MaxPossibleSum.cpp
#include <iostream>
#include <vector>
using namespace std;
int Max(int a, int b){
return a>b?a:b;
int Min(int a, int b){
return a<b?a:b;
View MultiStack.cpp
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
class SetOfStacks{
vector<stack<int>> stacks;
int threshold;
View RotateMatrix.cpp
template<int N>
void rotate90Clockwise(int (&matrix)[N][N]){
//Transpose the matrix
int temp;
for(int i=0;i<N;i++){
for(int j=0;j<i;j++){
View FindSortedShifted.cpp
int find(vector<int> elements, int start, int end, int key){
if(start>end) return -1;
int mid = start + (end-start)/2;
if(elements[mid]==key) return mid;
if(key>=elements[start] && key<elements[mid]) return find(elements,start,mid-1,key);
else return find(elements,mid+1,end,key);
View LongestCommonPrefix.cpp
int LCPLength(vector<string> input){
//Find the length of shortest string in the input set
int minLen = INT32_MAX;
for(int i=0;i<input.size();i++){
if(input[i].length()<minLen) minLen=(int)input[i].length();
bool done = false;
int lcpLen=0;
aaani /
Last active Dec 21, 2015
Here is a Java implementation of merge sort. This algorithms runs in O(n*log(n)) worst case time and O(n) space, where n is the input size. It's a stable sort, commonly used in sorting from disk.
import java.util.ArrayList;
* @author anirvana
public class MergeSort {
public static void main(String[] args) {
ArrayList<Integer> elements=new ArrayList<Integer>();
You can’t perform that action at this time.