Skip to content

Instantly share code, notes, and snippets.

@manuchandel
manuchandel / io.cpp
Created February 8, 2017 13:26
Fast I/O in C/C++
/*
grab the whole line
char a[100];
cin.getline(a,100);
scanf("%[^\n]",a);
gets(a);
*/
inline void fastRead_int(int *a)
{
@manuchandel
manuchandel / vocabulary.py
Created June 30, 2016 10:45
contains English stop words, question words, first person words. can be used for NLP
#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', '
@manuchandel
manuchandel / tweet_dumper.py
Created June 30, 2016 09:00 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into JSON
#!/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 = ""
@manuchandel
manuchandel / minJumps.cpp
Created October 2, 2015 15:49
Minimum number of jumps to reach end
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;
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;
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;