Skip to content

Instantly share code, notes, and snippets.

View rohith2506's full-sized avatar

Rohith Uppala rohith2506

View GitHub Profile
@rohith2506
rohith2506 / ncr.cpp
Created February 7, 2013 13:53
Binomial coefficient calculation using pascal triangle
/*
Ncr using pascal triangle
@author: rohit
pretty dynamic programming approach
space complexity:-0(n^2)
time complexity:-0(1)
in make_pascal_2()
space complexity :- 0(k)
time complexity :- o(n*k)
@rohith2506
rohith2506 / power.cpp
Last active December 12, 2015 06:59
power of function using fast exponentiation and divide and conquer method
/*
finding power of a^b mod M
@author : rohit
functions :-
1)power():-
rule:- x^n= (x^2)^(n/2) if(n is even)
x^n= x* (x^2)^(n-1/2) if(n is odd)
space complexity:- O(1)
time complexity :- O(n)
@rohith2506
rohith2506 / ratmaze.cpp
Created February 8, 2013 18:21
Classical Rat Maze Problem
/*
test[i][j] means to find number of ways it can be done
classy problem
*/
#include <stdio.h>
#include <iostream>
#define M 10
using namespace std;
@rohith2506
rohith2506 / subset.cpp
Last active December 12, 2015 10:49
To find Subsets using bit masks..:-)
/*
bit mask operations:-
1)shift left :- x<<1
2)shift right:- x>>1
3)and :- x&1
4)x|1 :- x|1
5)~x :- not x(flip every bit)
advanced bit mask operations:-
@rohith2506
rohith2506 / coin_change.cpp
Created February 12, 2013 11:44
coin change problem(classical dynamic programming problem)
/*
Coin change problem (classical dynamic programming problem)
@author : rohit
*/
#include <iostream>
#include <stdio.h>
#include <vector>
#define INF 1e9
@rohith2506
rohith2506 / longest_sub_sequence.cpp
Created February 12, 2013 12:40
Longest non decreasing sub sequence(dynamic programming)
/*
to find longest non decreasing subsequence (another classical dp problem)
@author:rohit
*/
#include <iostream>
#include <stdio.h>
#include <vector>
#define MAX 10001
@rohith2506
rohith2506 / max_sum.cpp
Created February 12, 2013 12:55
maximum sum sub sequence (dp solution)
/*
maximum sub sequence in an array(dp solution)
@author:rohit
*/
#include <iostream>
#include <stdio.h>
#include <vector>
@rohith2506
rohith2506 / prime_sieve.cpp
Created February 12, 2013 13:11
To calculate prime numbers using sieve of erosthenes
/*
to calculate prime numbers using sieve of erosthenes
@author:rohit
*/
#include <iostream>
#include <stdio.h>
#include <cmath>
@rohith2506
rohith2506 / robertherb.cpp
Last active December 13, 2015 17:58
Topcoder 570-div2 medium problem solution:-
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
class Robertherb{
public:
@rohith2506
rohith2506 / 167_2.cpp
Created February 14, 2013 10:46
codeforces 167 div2 problem B:-
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
typedef long long int LL;
#define MAX 100100
LL arr[MAX];
using namespace std;