This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var GetXHR = (function() { | |
var module = {}; | |
module.sendRequest = function(url, callback) { | |
var req; | |
if (window.XDomainRequest) { | |
req = new XDomainRequest(); | |
if (!req) return; | |
req.onload = function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MergeK | |
// | |
// Created by Anirvana Mishra on 6/18/13. | |
// Copyright (c) 2013 Anirvana Mishra. All rights reserved. | |
// | |
#include <iostream> | |
#include <vector> | |
#include <queue> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mancher.cpp | |
// | |
// Created by Anirvana Mishra on 6/30/13. | |
// Copyright (c) 2013 Anirvana Mishra. All rights reserved. | |
// Code is inspired by the algorithm explained here: http://wcipeg.com/wiki/index.php?title=Longest_palindromic_substring | |
#include <iostream> | |
#include <vector> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SuffixArray | |
// | |
// Created by Anirvana Mishra on 7/1/13. | |
// Copyright (c) 2013 Anirvana Mishra. All rights reserved. | |
// Code inspired by http://www.stanford.edu/class/cs97si/suffix-array.pdf | |
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Newton-Raphson | |
// | |
// Created by Anirvana Mishra on 6/29/13. | |
// Copyright (c) 2013 Anirvana Mishra. All rights reserved. | |
// | |
long double sq_root(double x) | |
{ | |
long double rt = 1, ort = 0; | |
while(ort!=rt) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findPower($base, $exponent){ | |
if($exponent==0) return 1; | |
$output=$base; | |
$p=1; | |
while($p*2<$exponent){ | |
$output*=$output; | |
$p+=$p; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
/** | |
* | |
* @author anirvana | |
*/ | |
public class MergeSort { | |
public static void main(String[] args) { | |
ArrayList<Integer> elements=new ArrayList<Integer>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(elements[mid]>=elements[start]){ | |
if(key>=elements[start] && key<elements[mid]) return find(elements,start,mid-1,key); | |
else return find(elements,mid+1,end,key); | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++){ | |
temp=matrix[i][j]; | |
matrix[i][j]=matrix[j][i]; | |
matrix[j][i]=temp; | |
} |
OlderNewer