Re: [algogeeks] SDE-1 openings in Amazon

2014-12-02 Thread sourabh jain
Location? Thank You Have a Nice Day :) Regards Sourabh Kumar Jain Computer Science Corporation(CSC) Hyderabad, Telangana. MOB.-+91916049 +919993878717 On 2 December 2014 at 15:44, Bhanu Kishore wrote: > Hi, > We have 4 SDE-1 openings in our team at Amazon Hyderabad.

Re: [algogeeks] Find the max element of sets of size K

2013-09-18 Thread sourabh jain
unsubscribe from this group and stop receiving emails from it, send an >> email to algogeeks+unsubscr...@googlegroups.com. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this g

Re: [algogeeks] Re: determine if 2 BSTs will be identical or not based on input order of its keys

2013-07-14 Thread sourabh jain
You don't need to take vector for this you can have input in array also. You just need to check the elements in each partition . On 12-Jul-2013 8:27 PM, "Don" wrote: > Can anyone modify this solution so that it does not duplicate the memory > at each level of recursion? > > (Here is my solution w

Re: [algogeeks] Re:

2013-06-21 Thread sourabh jain
t; group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to algogeeks+...@**googlegroups.com. >>> >>> >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] kth smallest element in 2 sorted arrays

2013-06-13 Thread sourabh jain
> plz suggest algo > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > > > -- Re

Re: [algogeeks] Re: t9 dictionary

2013-06-09 Thread sourabh jain
You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Amazon interview Questions

2013-06-09 Thread sourabh jain
Hi ravi , I think he is trying to find the longest possible increasing chain in matrix . he needs to start traversing from first row choosing columns one by one and move in all direction. but he needs to maintain the already visited nodes. On Thu, Jun 6, 2013 at 12:07 AM, sourabh jain wrote

Re: [algogeeks] Amazon interview Questions

2013-06-09 Thread sourabh jain
remaining so 4 will come on right node. On Wed, Jun 5, 2013 at 5:14 PM, Ravi Ranjan wrote: > Can u clear Round3 --- Qstn-3. the language is not cleared > > > On Wed, Jun 5, 2013 at 1:52 PM, sourabh jain wrote: > >> Round 1: >> 1.Design a Data Structure supporting 3 q

Re: [algogeeks] Minimum number of coins to SUM to S

2013-06-09 Thread sourabh jain
quot;Algorithm Geeks" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to algogeeks+unsubscr...@googlegroups.com. >>> >>> >>> >> >> -- >> You received this message because you are subscribe

Re: [algogeeks] Amazon interview Questions

2013-06-05 Thread sourabh jain
eks+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > -- > Thx, > --Gopi > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Infinite stream , identify distinct k kintegers

2013-06-05 Thread sourabh jain
> -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Infinite stream , identify distinct k kintegers

2013-06-05 Thread sourabh singh
for each num instream inserting num to stl::set() if size of set == k break O(nlogk) On Sun, Jun 2, 2013 at 10:49 AM, MAC wrote: > Given an infinite stream of integers with only k distinct integers, find > those distinct integers. How would you modify your solution if k is als

Re: [algogeeks] Re: Amazon Interview Question

2013-03-20 Thread sourabh jain
.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiv

[algogeeks] Cyclic sorting problem

2013-03-12 Thread sourabh jain
output : 2 -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups

Re: [algogeeks] Print tree node which sum

2013-03-12 Thread sourabh jain
ks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You rec

Re: [algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-12 Thread sourabh jain
iving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Regards, Sourabh Kumar Jain +91-8971547841 -- You received this message because you are subscribed to the Google Groups "A

Re: [algogeeks] Re: Amazon Interview Question

2013-02-16 Thread sourabh jain
>> > > Regards, >> > > Sachin Chitale >> > > Application Engineer SCJP, SCWCD >> > > Contact# : +91 8086284349, 9892159511 >> > > Oracle Corporation >> > >> > > -- >> > > You received this message because you

Re: [algogeeks] Re: Amazon Interview Question

2013-02-13 Thread sourabh jain
ups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Regards, > Sachin Chitale > Application Engineer SCJP, SCWCD > Contact# : +91 8086284349, 9892159511 > Oracle Corporation > > -- > Y

Re: [algogeeks] Amazon interview Question

2013-02-12 Thread sourabh jain
special value so for 3rd time no need to touch the linked list. while printing the result print first k integers from linked list. On Fri, Feb 8, 2013 at 9:46 AM, bharat b wrote: > @sourabh : how do u find whether the element in stream gets repeated in > heap.--> O(n) time...totally its O

Re: [algogeeks] Amazon interview Question

2013-02-07 Thread sourabh jain
; Ph: +91 9473629892 > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to algogeeks+unsubscr...@

[algogeeks] spoj problem EASYMATH

2012-06-24 Thread Sourabh Singh
please suggest something : Problem : http://www.spoj.pl/problems/EASYMATH/ C++ code : http://ideone.com/r2OSb was getting wrong ans due to over flow i think in LCM() for big prime's i guess. thin tried in python . Now getting NZEC for python code which mean's high level or recurrsion some where

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Sourabh Singh
an Monfared wrote: > just found a good resource for 1d and 2D version : > http://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf > > > On Sun, Jun 24, 2012 at 3:31 AM, sengar.mahi wrote: >> >> @adarsh :its nt dat easy as u see it.. >> >> &g

Re: [algogeeks] 4Sum

2012-06-23 Thread Sourabh Singh
@ Amol Sharma thanx got it.. yup, overlooked those case's :-) my bad.. On Sat, Jun 23, 2012 at 1:31 PM, Amol Sharma wrote: > @sourabh: > for this particular question.. > in your code replace > > if(binary_search(c,c+size,-b[i])) > count++; > > by > &g

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Sourabh Singh
@adarsh kumar are u sure it's worst case will be O (log n) ?? i think iff array is fully sorted O(n) will be required to say "NO such element present" On Sat, Jun 23, 2012 at 1:11 PM, adarsh kumar wrote: > This is a variation of binary search, the difference being that we have to > search for an

Re: [algogeeks] 4Sum

2012-06-23 Thread Sourabh Singh
@ALL O(n^2 lg(n^2)) http://www.spoj.pl/problems/SUMFOUR/ my code : http://ideone.com/kAPNB plz. suggest some test case's : On Sat, Jun 23, 2012 at 6:59 AM, Amol Sharma wrote: > @bhaskar,rammar: > > I don't think your algo willn not work for the following test case -- > > > test case : > arr

Re: [algogeeks] Re: Question asked in Amazon online test

2012-06-23 Thread Sourabh Singh
@deepika anand solution given by me is for getting number of swap's in O(n) as far as sorting goes any O(n lgn) algo can be used . if count sort is allowed then O(n) for sorting also.[constant extra space.. ] On Sat, Jun 23, 2012 at 12:49 AM, ashish jain wrote: > @all > > yaa.. For getting nu

Re: [algogeeks] Re: Question asked in Amazon online test

2012-06-23 Thread Sourabh Singh
#x27;s will give no. of swaps. > > correct me if i am wrong > > > On Sat, Jun 23, 2012 at 12:19 PM, Sourabh Singh > wrote: >> >> @deepika >> >> yes, it's giving number of swaps. >> still Linear time solution would be better :-) >> >>

Re: [algogeeks] Re: Question asked in Amazon online test

2012-06-22 Thread Sourabh Singh
@deepika yes, it's giving number of swaps. still Linear time solution would be better :-) On Fri, Jun 22, 2012 at 11:38 PM, deepikaanand wrote: > > will bubble sort give number of swaps?? > > I tried the (bubble sort) code of 1,0,0,1,1,0,1 >swapcount = 5 > and for the array  (0,0,1,0,1,0,1,1

Re: [algogeeks] Programming Question

2012-06-22 Thread Sourabh Singh
u can use stl::map(,vector) idea is same bucket sort :-) On Fri, Jun 22, 2012 at 3:02 AM, Eshwar wrote: > Bucket sort algortihm Linkedlist based > > > On Fri, Jun 22, 2012 at 3:31 PM, Gobind Kumar Hembram > wrote: >> >> I was asked this question in one company Programming Round.Please help >> me

Re: [algogeeks] Re: Sorting using array of pointer

2012-06-22 Thread Sourabh Singh
Nice DCE vs NSIT On Fri, Jun 22, 2012 at 3:12 AM, deepikaanand wrote: > @vindhya thanx .. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this g

Re: [algogeeks] Reverse Queue

2012-06-21 Thread Sourabh Singh
@ALL this shud work :-) #include #include using namespace std; queue Q; void rev() { if(!Q.empty()) { int x=Q.front(); Q.pop(); rev(); Q.push(x); } } main() { for(int i=1;i<12;i++) Q.push(i); rev(); while(!Q.empty()) { int x=Q.front(); Q.pop();

Re: [algogeeks]

2012-06-21 Thread Sourabh Singh
>> wrote: >>> >>> @umer >>> it's not random,but biased >>> >>> >>> On Wed, Jun 20, 2012 at 11:16 AM, Umer Farooq >>> wrote: >>>> >>>> Hmmm, true. That's what I expected in this solution. Similarly

Re: [algogeeks]

2012-06-21 Thread Sourabh Singh
> >> On Wed, Jun 20, 2012 at 11:16 AM, Umer Farooq wrote: >>> >>> Hmmm, true. That's what I expected in this solution. Similarly, we can >>> get 3 by (3,3) (1,2) >>> >>> However, did you take a look at the other solution I proposed? I guess

Re: [algogeeks] Re: POSTAGE STAMP PROBLEM

2012-06-19 Thread Sourabh Singh
try this : similar problem http://www.spoj.pl/problems/NOCHANGE/ On Tue, Jun 19, 2012 at 1:32 PM, aditya gupta wrote: > this can be solved in a manner similar to knapsack problem. > u can take the weight of tha knapsack the be the the various amounts u need > to make, 13 cents etc etc. we would

Re: [algogeeks]

2012-06-19 Thread Sourabh Singh
@Umer and Navin : 1 is generated by (1,3) only. 2 is generated by (1,1) and (2,3). so given solution is wrong On Tue, Jun 19, 2012 at 5:17 AM, Sourabh Singh wrote: > @ *ALL* > > please. post along with your method . > proof than it make's equal distribution over the gi

Re: [algogeeks]

2012-06-19 Thread Sourabh Singh
o better try this: rand(5) + (rand(5)%3). > > > On Tue, Jun 19, 2012 at 2:45 PM, Umer Farooq wrote: > >> rand(5) + (rand(5)%2); >> >> >> On Tue, Jun 19, 2012 at 12:30 PM, Sourabh Singh > > wrote: >> >>> @ sry >>> condition should b

Re: [algogeeks]

2012-06-19 Thread Sourabh Singh
@ sry condition should be: if(20*prob <= 500/7) :-) On Tue, Jun 19, 2012 at 12:26 AM, Sourabh Singh wrote: > @ALL > > Given a random number generator say r(5) generates number between 1-5 > uniformly at random , use it to in r(7) which should generate a random > number betwee

[algogeeks]

2012-06-19 Thread Sourabh Singh
@ALL Given a random number generator say r(5) generates number between 1-5 uniformly at random , use it to in r(7) which should generate a random number between 1-7 uniformly at random i have seen this on many site's but not a single correct solution. all solution's posted got rejected by someone

Re: [algogeeks] Find the Max from each sub-array of size k

2012-06-16 Thread Sourabh Singh
@ALL can be solved using segment tree . :-) On Fri, Sep 2, 2011 at 9:49 AM, Anup Ghatage wrote: > I just checked Shashank's blog post. The Deque solution is awesome :) > > -- > Anup Ghatage > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" gr

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Sourabh Singh
@ Navin Kumar Nice . Solution. But your function also make a stack only. so you are using a stack[internal] here. but may be this one is allowed:-) On Thu, Jun 14, 2012 at 5:23 AM, Navin Kumar wrote: > void Reverse(struct Stack *S) { > int data; > if(IsEmptyStack(S)) return; > d

Re: [algogeeks] Re: spoj problem

2012-06-13 Thread Sourabh Singh
@ saurabh singh : what algorithm can be used ?? coz.. i did it by simple observation. 1) just take any sequence of numbers. 2) write it's first 5-6 xor round's. 3) now luk for some pattern. u'll get the answer : ) On Wed, Jun 13, 2012 at 9:46 PM, saurabh singh wrote: > No this is f

Re: [algogeeks] Matrix Minimum Path Sum

2012-06-06 Thread Sourabh Singh
Basic Dijikstra problem . :-) On Wed, Jun 6, 2012 at 6:13 AM, Dheeraj Jain wrote: > http://www.geeksforgeeks.org/archives/14943 > > > On Mon, Jun 4, 2012 at 7:57 PM, Decipher wrote: > >> @Victor - Someone had asked this question from me !! He told me its from >> Project Euler Q-83. >> @Hassan

Re: [algogeeks] Find the maximum boxes which can fit each other?

2012-03-24 Thread sourabh datta
@atul.. i think what u meant is longest decreasing sequence.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr..

Re: [algogeeks] GSOC help android app inventor

2012-03-23 Thread Sourabh Chandak
ld i contact them? > > On 3/23/12, Sourabh Chandak wrote: > > Hi Raghav, > > > > I dont have much idea about the organisation. I gave a look at the idea > > page while searching for an organisation to work for, and this is what I > > could figure out. > > &g

Re: [algogeeks] GSOC help android app inventor

2012-03-23 Thread Sourabh Chandak
eeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sourabh Chandak -- You received this message because you are subscribed to the G

Re: [algogeeks] Google written test

2012-03-17 Thread Sourabh Chandak
ot;Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. &

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-15 Thread Sourabh Singh
} getch(); } On Wed, Mar 14, 2012 at 8:59 PM, atul anand wrote: > @Sourabh : here we are talking abt 2 different problems in this > post..which are little bit similar. > > 1) original question says find max subset of matix contaning '1' and '0' > >

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-14 Thread Sourabh Singh
printf(" %d",a[i][j]); } printf("\n"); } printf("\n\n\n\n\n"); for(i=0;i<6;i++) { for(j=0;j<6;j++) {printf(" %d",b[i][j]); } printf("\n"); } getch();

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-14 Thread Sourabh Singh
tually i faced it >> first tym...it executes...but explain plz.. >> >> On Wed, Mar 14, 2012 at 6:56 PM, Sourabh Singh >> wrote: >> >>> @atul >>> >>> Also the histogram algo and algo given by you can't work on very ve

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-14 Thread Sourabh Singh
@atul Also the histogram algo and algo given by you can't work on very very big dimentions. say 10^5 x 10^5 matrix. but if we can find a DP then we just need to keep 2 row's at a time. :-) On Tue, Mar 13, 2012 at 1:03 PM, Sourabh Singh wrote: > @atul > > read it .. > &

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread Sourabh Singh
width " " " " " " " hl:height of max rectangle possible at index left of current wl: """ " " "" now problem is which one to take for current... inde

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-13 Thread Sourabh Singh
@ ALL finding square matrix is quite a standard question and nw an easy one as everyone knows the reccussence atul has given. but i wanted to find max rectangle.. i know there is a DP for it. in O(n^2). for nxn matrix..don't know the whole approach .but here is what i remember.. 1. aproach i

Re: [algogeeks] Re: Amazon ques

2012-01-27 Thread Sourabh Singh
@all plz.. tell if this thing would work.. assume 2 in place of every 0 in array. ie 1 1 0 0 0 1 0 1 be 1 1 2 2 2 1 2 1 then find max sub array wid sum length/2 * 3. this can be done in O(n) but worst case would still be O(n lgn) . On 1/26/12, Sanjay Rajpal wrote: > +1 > * > Sanjay Kumar >

Re: [algogeeks] Re: sort 2D array

2012-01-27 Thread Sourabh Singh
@all I have come across this question earlier. it's a young's tableaus ( cormen pg. 167 ) can be treated as min heap. solution can be found in mit online study material. i'll post the link here as soon as i remember it. On 1/24/12, atul anand wrote: > @praveen : k way merge would require extra

[algogeeks]

2012-01-27 Thread Sourabh Singh
@ALL //Imagine that you write down all numbers between A and B in 2's complement representation using 32 bits. How many 1's will you write down in all ? wat's wrong with this code working fine for all cases i tested but on http://www.spoj.pl/problems/CODESPTA/ wrong answer.. plz.. point ou

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
@all sorry .. 21 is prime :-) hw can above algo be well implemented to get mpow function... On 1/18/12, Sourabh Singh wrote: > @All > > pow() mod is giving problem... > > found an algo .. is some1 intrested to discuss... > > Example: > Take 3^2

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
, Terence wrote: > error in pow. > as long as n < 2^31, x*x fits into int64_t, since x > On 2012-1-18 20:51, Sourabh Singh wrote: >> @ Terence >> >> I belive nw its giving wrong answer for n>41 onwards >> due to error's in pow and x*x over flow as u alre

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
@ Terence I belive nw its giving wrong answer for n>41 onwards due to error's in pow and x*x over flow as u already stated... i guess algo is right nw.. ;-) thanx again.. On 1/18/12, Sourabh Singh wrote: > @ thanx got it.. silly mistakes ;-) . missed thought it ws + betwee

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
; int r; for(r=1;r wrote: > @Sourabh > > m=2^s***d > primes[i]*<*n > > > > On 2012-1-18 19:39, Sourabh Singh wrote: >> @Terrence >> >> sry i didn't explain what s,d were they were also wrong i ws >> calculating for n not n-1 >> e

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
ulo-n method. >> >> 3. for big n, (exceed 32bit), x=(x*x)%n can be overflow also. you may >> need to implement your own multiply method in this case. >> >> >> On 2012-1-18 18:15, Sourabh Singh wrote: >>> @all output's to above code are just random..

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
(d&1)==0) d>>=1; > > 2. the accuracy of pow is far from enough. you should implement your own > pow-modulo-n method. > > 3. for big n, (exceed 32bit), x=(x*x)%n can be overflow also. you may > need to implement your own multiply method in this case. > > > On 2012

Re: [algogeeks]

2012-01-18 Thread Sourabh Singh
@all output's to above code are just random.. some prime's. found correctly while some are not why i used certain primes to check ie.(2,3,31,73,61,7) coz.. its given n wiki for about 10^15 checking with these is enough.. On 1/18/12, Sourabh Singh wrote: > @ALL hi everyone m trying

[algogeeks]

2012-01-18 Thread Sourabh Singh
@ALL hi everyone m trying to make prime checker based on miller-rabin test . can some1 point out . wat's wrong with the code. thank's alot in advance... //prime checker based on miller-rabin test #include #include #include int is_prime(int n) { if(n==2 | n==3) return

Re: [algogeeks] Re: DP problems in SPOJ

2011-12-28 Thread sourabh singh
60704 17592186044416 1413883960704 On Tue, Dec 27, 2011 at 11:20 PM, sourabh singh wrote: > @all > > plz point out wat's wrong with this code. works for small numbers but > fails for large number's > > #include > #include > using namespace std; > unsigne

Re: [algogeeks] Re: DP problems in SPOJ

2011-12-27 Thread sourabh singh
@all plz point out wat's wrong with this code. works for small numbers but fails for large number's #include #include using namespace std; unsigned int find_nCp(unsigned int n,unsigned int p) { unsigned int j=p; unsigned int num=1,den=1; for(;j;j--) num*=n--;

Re: [algogeeks] Re: DP problems in SPOJ

2011-12-27 Thread sourabh singh
@All i was searching fr some better way for i/o . i came across this code and many similar examples on net. i think asm can provide a way to load .output directly nd take input directly from i/o registers . but due to me being new to asm these code's are giving me trouble. It's an AT&T type asm

Re: [algogeeks] Re: doubt in spoj 8473 ways

2011-12-17 Thread sourabh singh
@anubhav No,i can't post an AC code here . takes all fun out of spoj problem solving thing. i can just hint that i used the function posted earlier and u don't need to make a function single for loop will do. that's it try harder. buddy :-) btw it got ac 111 later :-). On Sat, Dec 17, 2011

Re: [algogeeks] Re: doubt in spoj 8473 ways

2011-12-17 Thread sourabh singh
@all got AC 114 still i think without some other way to input/output it hard to get below 100. can some1 suggest some better (smaller ) way to i/o integers On Sat, Dec 17, 2011 at 1:31 AM, sourabh singh wrote: > @anubhav i too didn't find it on google bt may be it is: > > f(

Re: [algogeeks] Re: doubt in spoj 8473 ways

2011-12-17 Thread sourabh singh
@anubhav i too didn't find it on google bt may be it is: f(n)= ((4n-2)/n)*f(n-1)n>1 2 n=1 On Fri, Dec 16, 2011 at 8:07 AM, anubhav raj wrote: > @samm:i hv googled it several time bt by code no & path r ways as a tag bt > cudnt get ne link..cn u plz

Re: [algogeeks] doubt in spoj 8473 ways

2011-12-16 Thread sourabh singh
limit is just v.smll can ny1 help me with this code: [ c code ] get it under 120 bytes . is there any way to take inputs. without using scanf ??? in c . m thinking about inputs getting into argc array directly.??? #define s(n) scanf("%d",&n); f(int n){return n==1?1:(n*f(n-1));} main() { i

Re: [algogeeks] doubt in spoj 8473 ways

2011-12-15 Thread sourabh singh
yup it can be further reduced but i think u need a new approach. (m,m) is a big hint . try some nCp type of solution. #define s(n) scanf("%d",&n) #define I int I a[14][14],t,n; I d(I m,I n) { I s=a[m][n], k=(!m||!n)?1:(s?s:d(m-1,n)+d(m,n-1)); s=k;return k; } main() { s(t); while(t-

Re: [algogeeks] Re: Sub-array problem

2011-12-07 Thread sourabh singh
} >> while (newTemp > iLotteryPrice); >> >> // better solution >> bestPotential.nSum = newTemp; >> bestPotential.nEndIndex = i; >> bestPotential.nStartIndex += nStepCount; >> } >> >> if (bes

Re: [algogeeks] Re: Sub-array problem

2011-12-07 Thread sourabh singh
um = newTemp; > bestPotential.nEndIndex = i; > bestPotential.nStartIndex += nStepCount; > } > > if (bestPotential.nSum > bestDeal.nSum) > { > bestDeal = bestPotential; > } > } > > return 0

Re: [algogeeks] Re: Sub-array problem

2011-12-06 Thread sourabh singh
@ sourabh :-) yep, got your point... it wont work for all cases. but if we set initial max to a negative value . say max possible 64 bit -ve number.then ? point is though the code has limitations it will work fine mostly. On 12/5/11, sourabh wrote: > @sourabh singh.. > > Hey u don&

[algogeeks] Re: Sub-array problem

2011-12-05 Thread sourabh
@sourabh singh.. Hey u don't need an example... I see a check "sum > max" in ur code to calculate the max value, ryt ? Now ur initial value of max is set to 1. That means ur always assuming that the value whose closest is to be found is >= 1 , which is incorrect. What do you

Re: [algogeeks]

2011-12-05 Thread sourabh
This problem is a direct implication of "next_permutation" defined in C ++ STL algorithms. 1) From the end, keep decrementing till A[i] < A[i+1].. 2) Now, find the closest element , greater than equal, to A[i] in A[i +1 ... n]. Say, the index of the found element is "j". 3) Swap (A[i], A[j]) 4) Re

Re: [algogeeks] Re: Sub-array problem

2011-12-05 Thread sourabh singh
@ sourabh tried some cases its working on -ve as well. pls post some case in which it might not work. On 12/5/11, sourabh wrote: > @sourabh.. > > I don't think it will work for all the cases.. did u consider negative > integers as well... what i can understand from the above

[algogeeks] Re: Sub-array problem

2011-12-05 Thread sourabh
@sourabh.. I don't think it will work for all the cases.. did u consider negative integers as well... what i can understand from the above code is that u have taken 2 pointers of which one points to the beginning of the subarray and other one at the end of the subarray and u r shiftin

Re: [algogeeks] Sub-array problem

2011-12-05 Thread sourabh singh
@ mohit my first post on here. this solution got ac in spoj main() { unsigned int n,m,sum,max,i,j; sum=0;max=1; n=in.ReadNextUInt(); m=in.ReadNextUInt(); unsigned int *a = new unsigned int[n]; unsigned

[algogeeks] Re: Maximal possible subsets Algorithm

2011-12-05 Thread sourabh
@ Piyush.. I have a doubt... Is there any significance of the value Vi, if yes then can u give an example. If not, then is your question about finding all maximum subsets where the addition of the weights results in maximum (each weight being considered only once)... Say for ex- The max weight is

[algogeeks] Re: Sub-array problem

2011-12-01 Thread sourabh
gt;                        else > >                        { > >                                max_limit_here = max_ending_here; > >                                max_ending_here = 0; > > >                        } > >                } > > >        } > > &

[algogeeks] Re: Sub-array problem

2011-12-01 Thread sourabh
and wrote: > yup i made some calculation error > > Now this algo works perfectly :) :) > > Thanks for your help and explanation :) :) > > > > > > > > On Thu, Dec 1, 2011 at 4:26 PM, sourabh wrote: > > @atul ... > > > Reply 1: > >

[algogeeks] Re: Sub-array problem

2011-12-01 Thread sourabh
est X ( where element < > = X ) > hence 12 is the answer. > > > > > > > > On Thu, Dec 1, 2011 at 3:11 PM, atul anand wrote: > > @sourabh > > > i guess you need to modify this statement :- > > > 3) Now for each element B[i][0] , do a (modified)

[algogeeks] Re: Sub-array problem

2011-11-30 Thread sourabh
und = no element found Hence the max closest to X is 12...and the sub array is A [ 2 .. 4 ] On Dec 1, 10:21 am, atul anand wrote: >  @sourabh : > > *Cumulative SUM* > > *i* > > 2 > > 0 > > 3 > >  1 > > 6 > >  2 > > 10 > >  3 > > 15

[algogeeks] Re: Sub-array problem

2011-11-30 Thread sourabh
a new max. no closest to X in step 4. Complexity = N (to create array B) + N log N (to sort) + N log N ( to solve the problem) = O(n log n) On Nov 30, 11:21 pm, sourabh wrote: > First i would like to rectify a editing mistake that is as foolws : > Say the found index after binary search is j

[algogeeks] Re: Sub-array problem

2011-11-30 Thread sourabh
ement found , closest to X = 6 + 0 =6 12 - 10 = 2 no need to execute this step as 10 > 12 / 2 , because 12-10 = 2 which is smaller than 12 and won't lie on the right half... Hence the max closest to X is 12...and the sub array is A [ B[i] [1] ... B[j][1] ] On Nov 30, 9:39 pm, atul anand

[algogeeks] Re: Sub-array problem

2011-11-30 Thread sourabh
Given array of integers A,  create an 2-d array B of size n*2 such that  B[i][0] = sum of all elements from A[0] to A[i], B[i][1] = i;Now sort array B based on B[i][0].. Now for each element B[i][0] ( till its smaller that equal to X), do a (modified) binary search  for the closest value smaller th

[algogeeks] Re: Sub-array problem

2011-11-30 Thread sourabh
Given array of integers A[n], create an array B[n] such that B[i] = sum of all elements from A[1] to A[i], Now sort array B, and for each element B[i] ( smaller that equal to X), do a (modified) binary search for the closest value smaller than equal to (X - B[i]) in array B[i+1... n] Keep track

[algogeeks] Re: Google Question--Suggest Algo

2011-11-28 Thread sourabh
an implementation of brute force where you are > > dealing with all cases valid in the range n/2k and 3n/2k without any > > optimization with regard to DP. Am i right? > > > On Nov 28, 2:17 am, sourabh wrote: > > > Consider the example that you have given: > &g

[algogeeks] Re: Google Question--Suggest Algo

2011-11-28 Thread sourabh
is an implementation of brute force where you are > > dealing with all cases valid in the range n/2k and 3n/2k without any > > optimization with regard to DP. Am i right? > > > On Nov 28, 2:17 am, sourabh wrote: > > > Consider the example that you have given: > &g

[algogeeks] Re: Google Question--Suggest Algo

2011-11-28 Thread sourabh
implementation of brute force where you are > > dealing with all cases valid in the range n/2k and 3n/2k without any > > optimization with regard to DP. Am i right? > > > On Nov 28, 2:17 am, sourabh wrote: > > > Consider the example that you have given: > &g

[algogeeks] Re: Google Question--Suggest Algo

2011-11-28 Thread sourabh
an implementation of brute force where you are > > dealing with all cases valid in the range n/2k and 3n/2k without any > > optimization with regard to DP. Am i right? > > > On Nov 28, 2:17 am, sourabh wrote: > > > Consider the example that you have given: > &g

[algogeeks] Re: Google Question--Suggest Algo

2011-11-28 Thread sourabh
O(N*K) On Nov 28, 1:04 pm, Nitin Garg wrote: > @Sourabh - whats the running time? > > > > > > > > > > On Mon, Nov 28, 2011 at 3:28 AM, Ankur Garg wrote: > > Cool Solution...I was thinking of DP but wasnt clear on the recurrence... > > > Nice think

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
2/4 + F(8, 2) , // this will yield the maximum sum.. 3/5 + F(7, 2) , 4/6 + F(6, 2) } Trace the above equation and you should get it.. On Nov 28, 12:57 am, Ankur Garg wrote: > Hey Sourabh > >

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
ving initial value to all such combination a value of -1. To store that the intermediate computations take an array Max[N][K], F(N,K) = Max[N][K] On Nov 28, 12:17 am, sourabh wrote: > Because in the previous example k = 3. > > On Nov 27, 10:46 pm, Piyush Grover wrote: > > > &

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
Because in the previous example k = 3. On Nov 27, 10:46 pm, Piyush Grover wrote: > Optimal split: [0,0][1,1][0,0][1,1][0,1][1,0] > Expected value of optimal split: 0 + 1 + 0 + 1 + 1/2 + 1/2 = 3 > why this is not the optimal split??? > > > > > > > > On Sun, Nov 27, 2011 at 6:58 PM, Ankur Garg wro

[algogeeks] COGNIZANT(CTS) HELP

2011-10-05 Thread sourabh jain
COGNIZANT(CTS) visited any clg? Share all info. Criteria, pkg etc writtern exam patern, que/ans interview. Thnx in adv. -- Regards SOURABH KUMAR JAIN MCA, NIT RAIPUR MOB.-+919993878717 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"

Re: [algogeeks] Re: Samsung campus visit

2011-10-02 Thread sourabh jain
gt;>> test ur c skill for c..ds simple and os simpleno need to > prepare > > >>> if know basics... > > >>> 25 dieasy.25 problem solving... > > >>> interviews will b easy to crack...once u done with test u have done > 90%

[algogeeks] cdoc

2011-09-29 Thread sourabh jain
cdoc visited anywhere? tell me details? Regards SOURABH KUMAR JAIN NIT RAIPUR -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this g

Re: [algogeeks] Samsung campus visit

2011-09-27 Thread sourabh jain
1, writin 50 que.. (20 frm DI, 5 frm Quanta, 25 frm puzzel) 2. technical written (20 frm c/c++, 5 frm DS, 5 frm OS) 3. technical interview ( c/c++, DS, OS) 4. HR interview (normal) -- Regards SOURABH KUMAR JAIN MCA, NIT RAIPUR MOB.-+919993878717 -- You received this message because you are

  1   2   >