Skip to content

Instantly share code, notes, and snippets.

View rohith2506's full-sized avatar

Rohith Uppala rohith2506

View GitHub Profile
@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 / 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 / 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 / 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 / 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)