Re: [algogeeks] Re: Amazon interview Question

2012-12-27 Thread Anurag Gupta
On Friday, December 14, 2012 11:56:16 AM UTC+5:30, tapan rathi wrote: For a given number, find the next greatest number which is just greater than previous one and made up of same digits. -- -- -- Regards Anurag Gupta IV Year Computer Engineering Delhi Technological University

Re: [algogeeks] Re: Amazon interview Question

2012-12-21 Thread Anurag Gupta
.However there is no need to sort. On Friday, December 14, 2012 11:56:16 AM UTC+5:30, tapan rathi wrote: For a given number, find the next greatest number which is just greater than previous one and made up of same digits. -- -- Regards Anurag Gupta IV Year Computer Engineering Delhi

Re: [algogeeks] Amazon interview Question

2012-12-16 Thread Anurag Gupta
loop from the end of given number till you get a digit less than the previously scanned digit.Let the index of that number be 'i' . if index = -1,then the given number is the largest one else do the following 1) swap the digit at the index i with the digit just greater than it in the scanned

Re: [algogeeks] direct i online test

2012-08-24 Thread Anurag Gupta
The complexity of above code is exponential. Here is the simple recurrence for the given problem F(n) = 2*F(n-1) + F(n-2) + F(n-3) for n = 4 where F(1) = 2 F(2) = 5 F(3) = 13 precompute the values and each query will then be O(1) On Thu, Aug 23, 2012 at 8:22

[algogeeks] Re: Question asked in Amazon online test

2012-06-23 Thread Anurag Gupta
if we just need to determine number of swaps, it can be Done in O(n) Ex : 11100010 start counting number of zeros from the end so we have zeroCount = 1 whenever we encounter a 1 we add current zeroCount to numberOfSwaps so numberOfSwaps = 1 and so on the final value of numberOsSwaps is the

Re: [algogeeks] how to solve

2012-04-10 Thread Anurag Gupta
+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Anurag Gupta III Year Computer Engineering Delhi Technological University (Formerly Delhi College of Engineering) -- You received this message because you are subscribed

[algogeeks] Re: Amazon question

2012-03-22 Thread Anurag Gupta
I think this works and the complexity is O(sqrt(n)) #includecmath #includecstdio #includeiostream #includecstring #includecstdlib using namespace std; # define INFY 17 int main() { int n, i, j; int val, minDiv, minDis; while(1) { cin n; minDis =

[algogeeks] MODULUS

2012-02-21 Thread Anurag Gupta
how can we take mod by a very large number for example 100283 int mod = 100283; ans % mod is not working Please Help -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: check Similar array

2012-01-09 Thread Anurag Gupta
What about this approach: First we will scan the first array and find the smallest number. if it is -ve then we increment all numbers in both the arrays by that number . This ensures that every integer in first array is = 0 some integers in 2nd one maybe -ve if it is,then two arrays are not

[algogeeks] SuperSum

2012-01-02 Thread Anurag Gupta
SuperSum is a function defined as: * SuperSum(0 , n) = n, for all positive n. * SuperSum(k , n) = SuperSum(k-1 , 1) + SuperSum(k-1 , 2) + ... + SuperSum(k-1 , n), for all positive k, n. Given k and n, return the value for SuperSum(k , n) modulo 17. 1=k=50 1=n=1,000,000,000 For Example:

[algogeeks] Re: Algm

2011-11-14 Thread Anurag Gupta
that means the range of input is 1 to n^3 i.e there are n numbers and the numbers can vary from 1 to n^3 On Nov 14, 3:48 pm, Carl Barton odysseus.ulys...@gmail.com wrote: Bit confused by your n^3. Could you clarify? In the mean time Radix is an O(n) sorting algorithm. Where n is the length

[algogeeks] Re: median from continuous stream

2011-11-08 Thread Anurag Gupta
read this http://www.geeksforgeeks.org/archives/14873 On Nov 8, 10:29 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand it...could someone

[algogeeks] Re: EOF

2011-09-07 Thread Anurag Gupta
@ kunal I was attempting this problem: http://www.spoj.pl/problems/NHAY/ here,input size of haystick is not limited so,can you tell me how to read the haystick. On Sep 7, 12:06 am, Kunal Patil kp101...@gmail.com wrote: If I understand question correctly, then just read as many characters as

[algogeeks] EOF

2011-09-06 Thread Anurag Gupta
how to read a string whose length is not known and string is so long that we can't read it all at once? input (i.e string) is terminated by EOF -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Anurag Gupta
@ Mehnaaz :the variable no_p will be equal to 0,since it is an external one so the declaration char p[no_p][max] is equivalent to p[0][max]; and size of p is zero. then how you can insert anything into it as you are doing in for loop? no_p may receive some non zero value afterwards but array p is

[algogeeks] Re: wht is d logic behind this

2011-07-29 Thread Anurag Gupta
you refer cormen too On Jul 29, 11:19 am, jagrati verma jagrativermamn...@gmail.com wrote:  an array containing +ve and -ve integers.find sub array with the largest sum -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Java Book

2011-06-13 Thread Anurag Gupta
Please suggest any good book for Java (for beginners) Thanks in advance :) -- 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] Re: RIDDLE OF THE DAY 29 april

2011-04-29 Thread Anurag Gupta
Maid was the criminal because she lied. The day was sunday and you don't get mails on sunday On Apr 29, 12:57 pm, Lavesh Rawat lavesh.ra...@gmail.com wrote: * RIDDLE OF THE DAY  A man was killed on Sunday morning. His wife found the body and called the police. The police arrived and