This file contains hidden or 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
/* | |
grab the whole line | |
char a[100]; | |
cin.getline(a,100); | |
scanf("%[^\n]",a); | |
gets(a); | |
*/ | |
inline void fastRead_int(int *a) | |
{ |
This file contains hidden or 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
#set of stop words in english language | |
stop_words=set(['a', 'about', 'above', 'across', 'after', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'among', 'an', 'and', 'another', 'any', 'anybody', 'anyone', 'anything', 'anywhere', 'are', 'area', 'areas', 'around', 'as', 'ask', 'asked', 'asking', 'asks', 'at', 'away', | |
'back', 'backed', 'backing', 'backs', 'be', 'became', 'because', 'become', 'becomes', 'been', 'before', 'began', 'behind', 'being', 'beings', 'best', 'better', 'between', 'big', 'both', 'but', 'by', | |
'came', 'can', 'cannot', 'case', 'cases', 'certain', 'certainly', 'clear', 'clearly', 'come', 'could', | |
'did', 'differ', 'different', 'differently', 'do', 'does', 'done', 'down', 'down', 'downed', 'downing', 'downs', 'during', | |
'each', 'early', 'either', 'end', 'ended', 'ending', 'ends', 'enough', 'even', 'evenly', 'ever', 'every', 'everybody', 'everyone', 'everything', 'everywhere', | |
'face', 'faces', 'fact', 'facts', 'far', 'felt', ' |
This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import tweepy #https://github.com/tweepy/tweepy | |
import json | |
import sys | |
#Twitter API credentials | |
consumer_key = "" | |
consumer_secret = "" |
This file contains hidden or 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 minJump(vector<int> &A) { | |
int i,n=A.size(); | |
if(n==1) | |
return 0; | |
int steps=1; | |
int currentMaxReachable=A[0]; | |
int maxReachable=A[0]; | |
for(i=0;i<=maxReachable;i++){ | |
if(i==n-1) | |
return steps; |
This file contains hidden or 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 KMP(string T,string p){ | |
int n=p.length(); | |
int N=T.length(); | |
int *A=new int[n]; | |
longestPrefixSuffix(p,A,n); // compute lps array | |
int i=0,j=0; | |
while(i<N){ | |
if(j==n){ // pattern found | |
delete []A; | |
return i-n; |
This file contains hidden or 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
void longestPrefixSuffix(string &p,int *A,int n){ | |
A[0]=0; | |
int i=1,j=0; | |
while(i<n){ | |
if(p[i]==p[j]){ // match found | |
A[i]=j+1; | |
i++; | |
j++; | |
}else if(j==0){ | |
A[i]=0; |