Re: [algogeeks] Re: Printing random word from file

2012-08-26 Thread Kunal Patil
values of n. Consider n = 3. Then since rand() takes on 2^31 values, rand()%3 cannot take on the values 0, 1, and 2 with equal probability since 2^31 is not divisible by 3. Dave On Saturday, August 25, 2012 1:44:03 PM UTC-5, Kunal Patil wrote: How about using rand()%n ?? Like, calculate

Re: [algogeeks] Re: Printing random word from file

2012-08-25 Thread Kunal Patil
How about using rand()%n ?? Like, calculate lucky_pos = rand()%n Then print word at lucky_pos th position... Am I missing anything? All words are still equiprobable to get printed right? On Aug 20, 2012 11:45 AM, Dave dave_and_da...@juno.com wrote: @Navin: Okay. Here is a paraphrase. Assume

[algogeeks] Spoj Domino Tiling

2012-02-09 Thread Kunal Patil
I am solving spoj problem Tiling a Grid With Dominoes.(http://www.spoj.pl/problems/GNY07H/).. I am not able to come up with a recurrence relation.. One of my friend said it has the recurrence relation as f(n) = f(n-1) + 5*f(n-2) + f(n-3) - f(n-4). I am not convinced and have trouble deriving this

Re: [algogeeks] array or matrix problems...anyone?

2011-11-01 Thread Kunal Patil
@shady: There were no specific constraints. Actually, they didn't expect any best solution. People who wrote brute force also got shortlisted. Brute force would be Just picking a number one by one from first row and then checking other rows for existence of this number. I think it is a O(n^3)

Re: [algogeeks] [SPOJ] ZSUM

2011-10-25 Thread Kunal Patil
Can you tell why (x * z * z) % MOD is different from (x * ( (z*z)%MOD) ) % MOD Again why ((x%MOD)*(z%MOD)*(z%MOD))%MOD is giving WA I thought of a simple examples like (100* 53*72) % 90 -- ((90+10)*53*72) % 90 -- (10*53*72)% 90 which is same as (100%90 * 53%90 * 72%90) % 90 Another

Re: [algogeeks] Re: Inplace Array Convertion

2011-10-15 Thread Kunal Patil
@Sunny: Thanks for the info !! That's gr8.. your logic also seems to be working perfectly fine.. On Sat, Oct 15, 2011 at 12:16 PM, shady sinv...@gmail.com wrote: u can always post the code.,... but before posting code, you must state your algorithm else code becomes useless for other users

Re: [algogeeks] New Group For Practicing and Learning Efficient Ways of Coding

2011-10-05 Thread Kunal Patil
Great work shady...+1 I was so bored of the company interview queries on this group.. Hope to see Real algorithmic discussion on the new group. On Wed, Oct 5, 2011 at 11:27 PM, KARTHIKEYAN V.B. algo...@gmail.com wrote: +1 -- You received this message because you are subscribed to the Google

Re: [algogeeks] Explain output

2011-09-29 Thread Kunal Patil
Why don't you post a code that compiles ? On Fri, Sep 30, 2011 at 12:41 AM, Brijesh brijeshupadhyay...@gmail.comwrote: void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i));

Re: [algogeeks] Re: Amazon OS question

2011-09-26 Thread Kunal Patil
Nice question nice answer... :) On Tue, Sep 27, 2011 at 6:25 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: what's the algo of this question On Mon, Sep 26, 2011 at 2:38 PM, vikas vikas.rastogi2...@gmail.comwrote: simple graph question, graph is given as list , just check the

Re: [algogeeks] output

2011-09-13 Thread Kunal Patil
@Kumar: +1 @Kumar Rajeshwar: ExitFailure is outputted because main is expected to return something which is not done in your case. Just add return 0; at the end of main to get expected output. On Tue, Sep 13, 2011 at 11:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: int main()

Re: [algogeeks] C Puzzle

2011-09-12 Thread Kunal Patil
Allocate memory for pointer variables. On Mon, Sep 12, 2011 at 11:03 AM, sukran dhawan sukrandha...@gmail.comwrote: run time error first int * a is not assigned some address... so it will be pointing to some garbage value second two pointers of different types without a typecast will result

Re: [algogeeks] Re: Amazon ques

2011-09-11 Thread Kunal Patil
@Brijesh: +1 On Sun, Sep 11, 2011 at 2:14 PM, Brijesh brijeshupadhyay...@gmail.comwrote: This is the fastest way I can think of to do this, and it is linear to the number of intervals there are. Let L be your original list of numbers and A be a hash of empty arrays where initially A[0] =

Re: [algogeeks] Re: Amazon ques

2011-09-11 Thread Kunal Patil
, 2011 at 4:20 PM, Ankur Garg ankurga...@gmail.com wrote: This solution is not in O(n) time :( Unfortunately interviewer wants O(n) . On Sun, Sep 11, 2011 at 4:01 PM, Kunal Patil kp101...@gmail.com wrote: @Brijesh: +1 On Sun, Sep 11, 2011 at 2:14 PM, Brijesh brijeshupadhyay

Re: [algogeeks]

2011-09-10 Thread Kunal Patil
@Piyush: +1 On Sat, Sep 10, 2011 at 1:07 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: pseudo algo: =array idx[0...k-1] indicates the current pointer position in the ith stream(initialized to 0). =heap tree of size k where each node stores value of the data and value of stream

Re: [algogeeks] Re: Kth largest element

2011-09-10 Thread Kunal Patil
@Dave: TC in your first case will be O(klogn + n). Transforming array into heap would be O(n). Correct me If i am wrong. -- 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

Re: [algogeeks] Re: worst case complexity

2011-09-10 Thread Kunal Patil
. :) :) On Sat, Sep 10, 2011 at 5:10 PM, Kunal Patil kp101...@gmail.com wrote: @Piyush: In 2 ways I will prove you wrong. 1) Lets take 2 innermost loops. for(j=0;ji*i;j++) { for(k=0;kj;k++) } Let i*i be m. Thus, It becomes. for(j=0;jm;j++) { for(k=0;kj

Re: [algogeeks] ACM

2011-09-08 Thread Kunal Patil
Cool.. If you can share/ask algorithm related programming questions.. :) In fact it is the main cause of this group. :) :) :) There are sufficient SPOJ problem discussions over here.. You can continue asking questions if you think, that particular problem needs special data handling techniques to

Re: [algogeeks] Re:

2011-09-06 Thread Kunal Patil
sizeof never executes whatever expression is given as parameter. It needs only size of parameter. In this case, parameter main() returns an int type. So sizeof returns sizeof int. It doesnt need to call main() to get its task, of finding size, done. On Tue, Sep 6, 2011 at 11:41 PM, siddharam

Re: [algogeeks] EOF

2011-09-06 Thread Kunal Patil
If I understand question correctly, then just read as many characters as you can using standard string functions. (like fgets n all related) Output these all characters in a file. Iterate until you have read all the characters and go on appending what you have read to file. You intended to ask

Re: [algogeeks] Re:

2011-09-06 Thread Kunal Patil
@siddharam suresh: sizeof(void) is an prohibited operation. So your code would result in compile time error. On Tue, Sep 6, 2011 at 11:47 PM, siddharam suresh siddharam@gmail.comwrote: my guess, sizeof() takes only the declaration properties not the definition properties(that means it

Re: [algogeeks] c doubt

2011-08-31 Thread Kunal Patil
@kartik: typedef struct { int bit1:29; int bit2:4; }bit; This makes total number of bits 33, which is not on int boundry. (multiple of 32 bits) So to make it aligned on int boundry, 31 extra bits are padded at the end of bit2. This makes size of struct 29 + 4 + 31 = 64 bits -- 8 bytes. When bit1

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Kunal Patil
@Dave: +1 for nice solution... :) On Sat, Aug 27, 2011 at 10:12 PM, Dave dave_and_da...@juno.com wrote: @Avinash: What do you mean by exceeding limit(already overflowed)? The number maxint is the limit. Every positive number is = maxint. Dave On Aug 27, 10:31 am, Avinash LetsUncomplicate..

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Kunal Patil
@Dave: Still your approach to solve the problem remains correct. (subtracting a number from max possible value then comparing this difference with another number). So, no need to think that you were brain dead (If you were, you would have posted a movie story here)..[?] Mathematically it is

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Kunal Patil
@Abhishek: Its not always that you reach a leaf through the node. But still your logic seems correct. There would be 3 candidates for minimum: --predecessor --current node --successor. On Sat, Aug 20, 2011 at 1:13 PM, Abhishek Yadav algowithabhis...@gmail.comwrote: No your solution is correct

Re: [algogeeks] Re: Possible solutions to these sort of Questions

2011-08-18 Thread Kunal Patil
+1 Yasir. On Wed, Aug 17, 2011 at 11:39 PM, Yasir yasir@gmail.com wrote: For questions specifically asking about test cases, I would suggest following 3 step approach: First think of a* basic flow that MUST work for the application* (what is expected with the application. Firstly make

Re: [algogeeks] Re: How to solve this problem

2011-08-14 Thread Kunal Patil
Yes..i agree with Dave..Here is what i think. As you have integers upto n^3 in your input, it would need [3*lg(n) + 1] bits to represent each integer. So take each group of r = ceil(lg(n)) bits at a time. So this becomes number of bits needed to represent single digit. Each digit thus can take 2^r

Re: [algogeeks] Re: an array question

2011-08-14 Thread Kunal Patil
: isn't it a simple question of applying radix sort from most significant to least signigicant digit and concatenating all the sorted numbers to get the largest number.. On Sat, Aug 13, 2011 at 11:13 PM, Kunal Patil kp101...@gmail.com wrote: Let me clarify. Lets take example

Re: [algogeeks] Re: logic???????????

2011-08-13 Thread Kunal Patil
@Yasir: Yups...I also have the same algo... Just to improvise your solution, you need not do binary search on both sides of the pivot. Just check End points (min-max) of the both sub-array to decide which side to do a binary search..This works in the case of duplicate elements too. for e.g. 2 5

Re: [algogeeks] Re: an array question

2011-08-13 Thread Kunal Patil
Following approach should work: 1) Count max number of digit in any integer of input. Let it be m. (Thanks to dave..) 2) For each int having less than m digits: Convert it to string of length m where you append circularly. For e.g. if m=5 53 -- 53535 100 -- 10010

Re: [algogeeks] Re: c output doubt

2011-08-13 Thread Kunal Patil
@rohit: Cast pointer to an integer into an int to get what you are expecting. for e.g. printf(%d,(int)a[4]-(int)a[0]); This will give 16. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: an array question

2011-08-13 Thread Kunal Patil
PM, aditi garg aditi.garg.6...@gmail.comwrote: @kunal: what is the best way to implement step 2? On Sat, Aug 13, 2011 at 7:33 PM, Ashish Sachdeva ashish.asachd...@gmail.com wrote: @kunal: seems fine.. tried it on some cases... On Sat, Aug 13, 2011 at 5:17 PM, Kunal Patil kp101

Re: [algogeeks] Re: an array question

2011-08-13 Thread Kunal Patil
equal to the max length of any number... whr r v doing dat chking in dis algo? On Sat, Aug 13, 2011 at 10:25 PM, Kunal Patil kp101...@gmail.com wrote: I dont know whether this is best approach to do step 2 or not. But it's certainly good. //I will show for two strings s1 and s2 len1 = s1

Re: [algogeeks] Re: Amazon question.

2011-08-10 Thread Kunal Patil
@Ankit Sambyal: Agree with ankuj...TC of your solution is O(nlogn) and not O(n^2)... -- 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

Re: [algogeeks] Re: m'th max element

2011-08-10 Thread Kunal Patil
@Ankuj: +1 for different approach. (Though selection algo is more efficient than this.) On Wed, Aug 10, 2011 at 1:44 PM, nick tarunguptaa...@gmail.com wrote: nice logic :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

Re: [algogeeks] Re: Amazon question.

2011-08-10 Thread Kunal Patil
@Ankit: Ohh Sorry..I didnt actually read the question properly.. I didnt see we have to check for sum which must be another element in the array not some user provided constant value..I mis-understood it with sum upto k problem which can be solved on sorted array in O(n)... thats why gave a wrong

Re: [algogeeks] xplanation plz

2011-08-07 Thread Kunal Patil
@Saurabh: +1 for your second code. On Sun, Aug 7, 2011 at 12:17 PM, Amol Sharma amolsharm...@gmail.com wrote: nice :) -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Aug 7, 2011 at 8:16 AM, saurabh singh saurab...@gmail.com wrote: Yup it

Re: [algogeeks] Re: Directi Question

2011-08-07 Thread Kunal Patil
Probability of getting an even sum in one roll is 1/2.. Thus, expected number of rolls required to get even sum is inverse of that i.e. 2. Alternatively, Going by basics... Let P(x) be probability of getting Even sum in x rolls. P(1) = 1/2(Even) P(2) = (1/2) * (1/2) (Odd + Odd) P(3) = (1/2)

Re: [algogeeks] Directi Question

2011-08-07 Thread Kunal Patil
@Shady : No...we can say this only at the time when following constraints are satisfied: 1) *Outcome* of event *should be* *binary*. (In above example Sum can have binary outcomes only i.e. EVEN or ODD) 2) Random variable x in P(x) should be supported on set {1,2,3,4,} i.e. It *should start

Re: [algogeeks] Re: Goldman sachs

2011-08-03 Thread Kunal Patil
I agree with Ved that Apti of GS is really really tough and technical is relatively easy..They ask CAT (Quant) like questions and you have to solve them in little time too...Also there will be sectional cut-off for this written test. So dont be afraid if you can solve only 10-15 questions from

Re: [algogeeks] Amazon Question

2011-08-03 Thread Kunal Patil
Sort both the lists... (Keep track of their original indices as we need to return to original list) Modify the merge process of merge_sort: // Assume size of list1 is m and that of list2 is n curr_list1=0;curr_list2=0;curr_output=0; while( curr_list1 m curr_list2 n ) { If

Re: [algogeeks] Re: latest google interview questions

2011-08-03 Thread Kunal Patil
@Shady: +1 But I cant stop laughing.[?] Hacking some1's account and doing such hilarious posts...[?] On Wed, Aug 3, 2011 at 9:55 PM, Anil Arya anilarya...@gmail.com wrote: @shadythank you very much .Good job On Wed, Aug 3, 2011 at 9:48 PM, shady sinv...@gmail.com wrote: utkarsh -

Re: [algogeeks] Re: Merging K-sorted lists using Heap

2011-08-02 Thread Kunal Patil
@Kumar:Thanks for the very good question and @Dave:Thanks for very very good solution... -- 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

Re: [algogeeks] Find the number of solutions.

2011-07-29 Thread Kunal Patil
x^(x^x) - (x^x)^x = 0 Thus, x^(x^x) = (x^x)^x Let's open it up by taking log on both sides... (x^x)*log(x) = x* log(x^x) (x^x)*log(x) = x*x*log(x) If x==1 equation is satisfied as log(x) becomes 0.. so x=1 is definitely a solution. what if when x != 1 cancelling log(x) on both the sides.. x^x =

Re: [algogeeks] Puzzle

2011-07-28 Thread Kunal Patil
Insufficient data to calculate what you need to find out !!! On Thu, Jul 28, 2011 at 9:39 PM, shubham shubh2...@gmail.com wrote: A man leaves his office daily at 07:00 PM. His driver arrives with the car from home to his office at sharp 07:00 PM. So he doesn't need to wait for any transport

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Kunal Patil
@Ankur Garg: Nice explanation at the link given by u... On Tue, Jul 26, 2011 at 10:35 PM, Ankur Garg ankurga...@gmail.com wrote: Check this http://codesam.blogspot.com/2011/03/find-all-subsets-of-given-set.html On Tue, Jul 26, 2011 at 9:41 PM, Vishal Thanki vishaltha...@gmail.comwrote:

Re: [algogeeks] Coding..........

2011-07-22 Thread Kunal Patil
@Sunny: Excellent explanation ( solution) !! -- 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

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread Kunal Patil
@surender: I assume you want to give general solution to Josephus problem in which we shoot every kth person...In that case formula for pos must be: pos = ( x*k )%n + (k-1) In current context, k=2...thus the formula which you gave also holds true..but not when k != 2 -- You received this

Re: [algogeeks] Counting the ways.

2011-07-15 Thread Kunal Patil
I agree with skript: Number of ways of doing this is n! One in the first row can be placed in n ways. After one in first row has been placed, we can place One in second row in n-1 ways and so on. So total num of ways is n*(n-1)*...*1 = n! One possible solution to this problem can be coded as

Re: [algogeeks] Finding the Kth Prime

2011-07-15 Thread Kunal Patil
@Antony: To post in this group..Just login to your gmail account. Compose new mail containing your question and send it to algogeeks@googlegroups.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] array or matrix problems...anyone?

2011-07-09 Thread Kunal Patil
I had one in my MS apti... Given a randomly generated 2 d matrix find an element which occurs in all 3 rows... On Sat, Jul 9, 2011 at 2:47 PM, Nitish Garg nitishgarg1...@gmail.comwrote: I think Strassen Algorithm is used to multiply Matrices efficiently. Read Cormen. -- You received this

Re: [algogeeks] array or matrix problems...anyone?

2011-07-09 Thread Kunal Patil
@My post: matrix was randomly generated 3X3 matrix...(Not any 2D matrix) On Sat, Jul 9, 2011 at 9:08 PM, Kunal Patil kp101...@gmail.com wrote: I had one in my MS apti... Given a randomly generated 2 d matrix find an element which occurs in all 3 rows... On Sat, Jul 9, 2011 at 2:47 PM

Re: [algogeeks] Longest substring 0's 1's

2011-07-05 Thread Kunal Patil
@Sunny : Excellent !!! Keep posting such nice solutions !! :) On Sat, Jul 2, 2011 at 1:47 AM, Anika Jain anika.jai...@gmail.com wrote: ohh ok i got it.. thanx :) On Sat, Jul 2, 2011 at 12:48 AM, sunny agrawal sunny816.i...@gmail.comwrote: it is (2,4] not [2,4]. open interval, close

Re: [algogeeks] Implementing QUEUE with Singly link list

2011-07-04 Thread Kunal Patil
@Sandeep: Without storing explicit pointer to last element, how would you be able to access last element in a Singly Linked List in O(1) ??? Is there any parallel data structure that needs to be maintained ?? and if it is larger than size of 2 explicit pointers to last and first elements then 2

Re: [algogeeks] [brain teaser ] Probability Riddle Loaded Revolver 13 june

2011-06-13 Thread Kunal Patil
Assuming everything is unbiased: probability of the next slot to contain a bullet (given, first was empty) would be (1/4) = 0.25 After spinning: prob(bullet) = (2/6) = 0.334... We want to minimize the probability... thus answer should be just to pull the trigger again.. On Mon, Jun 13, 2011 at

Re: [algogeeks] Re: Print 1 to n without loops

2011-06-13 Thread Kunal Patil
@Divye Kapoor : It was interesting...use of inheritance concept to print that... On Mon, Jun 13, 2011 at 12:09 AM, Divye Kapoor divyekap...@gmail.comwrote: This will probably be the best solution yet ;) Compile time template metaprogramming: templateint N class X : public XN-1 { public:

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread Kunal Patil
Yups...that seems best.. :) On Fri, Jun 10, 2011 at 4:03 PM, sunny agrawal sunny816.i...@gmail.comwrote: initialy cal size of queue then apply a for loop On Fri, Jun 10, 2011 at 4:00 PM, sunny agrawal sunny816.i...@gmail.comwrote: First algorithm taht comes in mind deque a element if

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Kunal Patil
IF allowed ??? If yes...Use recursion.. On Fri, Jun 10, 2011 at 9:12 PM, Navneet Gupta navneetn...@gmail.comwrote: Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use. --Navneet -- You received this message because you are subscribed to the Google

Re: [algogeeks] Reverse the bits.

2011-06-10 Thread Kunal Patil
How about this??? * unsigned int flip_j_to_k_bits (unsigned int n,unsigned int j,unsigned int k) { unsigned int temp; int num_of_on_bits = k-j+1; temp = (1num_of_on_bits)-1; temp = j; return (n^temp); }* I dont know whether shift operation is O(1) or not ! But i think

Re: [algogeeks] Re: Puzzle

2011-06-10 Thread Kunal Patil
@ross: seems logically correct..nice solution.. -- 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

Re: [algogeeks] Re: MS Interview

2011-06-10 Thread Kunal Patil
@ Dumanshu: With memory restriction also XOR method works.. :) In this case difference is just that you will be working with 400/ X number of files..where X is size of the RAM...just maintain a variable Curr_XOR_value and go on XORing it with element read from the file. When you are done

Re: [algogeeks] Re: get rid of sohail panzer spam

2011-06-08 Thread Kunal Patil
Automatic deletion will solve the trouble only for you not for the group as such messages are not reported spam.. [?] What i do is: When i login just type in search box 'panzer'...mark all...report spam and then delete from spam box..That way they are definitely reported as spams..[?] We can't

Re: [algogeeks] [brain teaser ] Find The Next Number 6 june

2011-06-08 Thread Kunal Patil
Ohh...that was a hard one...[?] On Tue, Jun 7, 2011 at 10:30 AM, shashankreddy509 shashankreddy...@gmail.com wrote: http://mathworld.wolfram.com/TwinPrimes.html http://mathworld.wolfram.com/TwinPrimes.html have look at this link... -- You received this message because you are subscribed

Re: [algogeeks] Microsoft ques : reverse of dutch national flag problem

2011-06-05 Thread Kunal Patil
Simple solution of order O(n^2), similar to bubble_sort, is obvious... Any improvements ??? On Sun, Jun 5, 2011 at 7:03 PM, Arunachala Karthik arunachalakart...@gmail.com wrote: What is the order of time specified in the question? On Thu, Jun 2, 2011 at 5:03 PM, siva viknesh

Re: [algogeeks] Stack and Permutation Problem

2011-06-05 Thread Kunal Patil
Manually calculated it to be 14.. [?] Can't think of any general formula but i think a formula or at least recursive function must be there to solve this. On Sat, Jun 4, 2011 at 1:01 PM, siva viknesh sivavikne...@gmail.com wrote: Stack A has the entries a,b,c ( with a on the TOp) Stack B is

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread Kunal Patil
If you are not going to allow extra space, you have to compromise on time complexity..[?] If you dont have your string already stored in a trie/hashmap usage of it requires additional buffer. Simple solution would be: Sort given string using in-place sorting algorithm and then removal of

Re: [algogeeks] Array Merge Problem

2011-06-03 Thread Kunal Patil
@Ashish: your solution is not O(N). I dont think you are taking advantage of the statement ( A and B need not be sorted in the end) @sravanreddy: excellent solution. On Thu, Jun 2, 2011 at 7:46 PM, Ashish Goel ashg...@gmail.com wrote: int i=lenA-1; int j=lenB-1; while (j=0) { if (A[i]

Re: [algogeeks]

2011-06-03 Thread Kunal Patil
Go to hell u spammer..[?] -- 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...@googlegroups.com. For more options,

Re: [algogeeks] [brain teaser ] Mystery Puzzle Sherlock Holmes 26 may

2011-06-03 Thread Kunal Patil
Hahaha..nice one.. :) :) On Thu, May 26, 2011 at 9:43 PM, DeVaNsH gUpTa devanshgupta...@gmail.comwrote: Mark as it reads ?(Question Mark) Crimson. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] MS Question

2011-06-01 Thread Kunal Patil
@Gaurav: You might want to say circular doubly linked list, didn't you ? coz without that, its not possible to reach last node if we are at first node or vice-versa. On Thu, Jun 2, 2011 at 9:31 AM, Gaurav Aggarwal 0007gau...@gmail.comwrote: other solution might be to use doubly linked list,

Re: [algogeeks]

2011-05-24 Thread Kunal Patil
@Piyush: I don't think 1010 (and any even number) will be a binary palindrome (Unless u allow single leading zero)...(Either you allow all or allow none) If its not so what about 1001 then ? Whether it will be a palindrome or not ?[?] Don't you think, it isn't possible to do this in less than

[algogeeks] 3 in 1 remote control

2011-05-21 Thread Kunal Patil
Not strictly an algorithmic question, rather a test-of-design-skills type of question. You are asked to design a 3-in-1 remote control for TV, a DVD player, and a cable box. How will you go with design ? In my approach it should have following buttons. 1) *Device Key* : Will represent device

Re: [algogeeks] Array problem

2011-05-19 Thread Kunal Patil
@ Piyush: Excellent Solution...It appears both Correct and O(n)...Good work !![?] Just a minor correction in your algo.[?] * while(B[i]C[j]) * * j++; must also check for J's bound as: **while ( j ( sizeof(A)/sizeof(A[0]) )* *B[i]C[j] ) j++; Or it will crash when

Re: [algogeeks] Array problem

2011-05-18 Thread Kunal Patil
@Amit: Ohh..Your test case is correct but not my solution..[?] It only works if it is guaranteed that one end will be at the extreme of the array ! (UseLess ! [?]) Sorry folks... So can anybody prove that O(n) solution does not exist for this problem? [?] -- You received this message because you

Re: [algogeeks] [brain teaser ] Greater than God Riddle 18 may

2011-05-18 Thread Kunal Patil
Hahaha...Nice answer Piyush ! On Wed, May 18, 2011 at 12:44 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: *NOTHING*. *Greater than GOD - NOTHING* *Worse than EVIL - NOTHING* *Poor have it and rich want it - NOTHING* *if you eat it, you die - NOTHING * On Wed, May 18, 2011 at 12:35

Re: [algogeeks] Array problem

2011-05-17 Thread Kunal Patil
Ohh..If it is so...Sorry !![?] I understood it the different way...[?] But if the question is as mentioned in your 2nd case then also I believe there is O(n) solution.[?] Maintain two pointers: *START* and *END* two variables: max1 and max2 Assume arr[MAX_SIZE] to be the array containing

Re: [algogeeks] Re: nearest neighbour

2011-05-17 Thread Kunal Patil
Nice explanation Dave..Thnx for the extra info !! On Tue, May 17, 2011 at 11:00 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote: thanks Dave :) This is a standard Google question On 5/17/11, Dave dave_and_da...@juno.com wrote: @Piyush. The simplest algorithm is to sort the array

Re: [algogeeks] Array problem

2011-05-16 Thread Kunal Patil
@Anuj Piyush: You didn't get the algo. It works on unsorted array also. You might have missed the statement *else // next element is smaller than or equal to current element reset curr_max to 1;* Here, the comment itself shows unsorted elements have been taken into consideration. If you

Re: [algogeeks] Puzzle

2011-05-14 Thread Kunal Patil
Each team plays a total of 14 matches. Top 50% teams(4 out of 8) qualify for the semis. Thus, u must win more than 50% matches to be sure to get into semis. Thus, 8 is the answer. On Fri, May 13, 2011 at 12:14 AM, amit amitjaspal...@gmail.com wrote: Consider a series in which 8 teams are

Re: [algogeeks] Re: FUN TEASER 11 may

2011-05-12 Thread Kunal Patil
@ Anil: +1 dude...Nice answer... On Wed, May 11, 2011 at 8:52 PM, anil chopra anil.chopra2...@gmail.comwrote: i will stop imaging. On Wed, May 11, 2011 at 7:38 PM, Dave dave_and_da...@juno.com wrote: I was on a river boat in Europe, and the emergency drill was to go to the upper deck and

Re: [algogeeks] Re: Candy_splitting in GCJ

2011-05-09 Thread Kunal Patil
OMG !!! Was it so easy I feel lyk crying that i didnt think of this...Really bad of mine.. [?][?] -- 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

Re: [algogeeks] [brain teaser ] Short Riddle 27 april

2011-04-30 Thread Kunal Patil
Must admit it was nice !!! Well use of English and sentence construction.. On Wed, Apr 27, 2011 at 1:59 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: * Short Riddle * *How far can a dog run into the forest? * *Update Your Answers at* : Click

Re: [algogeeks]

2011-04-21 Thread Kunal Patil
@Hary rathor: Your program also crash on my Dev-Cpp (Version 4.9.9.2)..Make sure whether it runs on your PC !! I don't know whether Literal can be type-casted... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] Sites for Interview Questions

2011-04-16 Thread Kunal Patil
geeksforgeeks.org BTW.. Thanks for creating this post...I have came across really nice sites that interest me in above replies.. -- 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.

Re: [algogeeks] ADULT SEX PHOTOS

2011-04-14 Thread Kunal Patil
@All : Please report it spam and then delete. Gmail will look into it if reported spam by many people. -- 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

Re: [algogeeks] regarding telephonic interview at Cisco

2011-04-08 Thread Kunal Patil
Friends in my class appeared for it recently. They were asked OS n Networking based questions. On Thu, Apr 7, 2011 at 11:09 PM, nitish goyal nitishgoy...@gmail.comwrote: If anyone had telephonic interview at cisco regarding summer internship, then please the experience asap. I am having this

Re: [algogeeks] [brain teaser ] 30march

2011-03-31 Thread Kunal Patil
Nice to See so many Kunal here !!! :P On Wed, Mar 30, 2011 at 11:42 PM, Kunal Yadav kunalyada...@gmail.comwrote: One is grandpa -- Regards Kunal Yadav (http://algoritmus.in/) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] [brain teaser ] 30march

2011-03-30 Thread Kunal Patil
Excellent answer Kunal !! On Wed, Mar 30, 2011 at 1:55 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: grandfather, father and son went for fishing... here we have two fathers and two sons On Wed, Mar 30, 2011 at 1:52 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Fishing Problem *

Re: [algogeeks] Announcing ITRIX OPC 2011

2011-03-28 Thread Kunal Patil
@rk: thnx... @raunak: https://www.spoj.pl/ITRIX11/problems/main -- 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

Re: [algogeeks] Announcing ITRIX OPC 2011

2011-03-28 Thread Kunal Patil
I am able to view the solutions but not able to get the logic behind it... Can you explain it...Or any1 who has solvd it can xplain !! A link, if any, to an article explaining logic behind it would be awesome... Also idea of writing an editorial explaining logic to solve problems in this contest

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-03-28 Thread Kunal Patil
@Bittu: Can you elaborate more how Constructing BST (I hope it stands for Binary Search Tree) would be o(n)... I think It would also be O(nlog(n))... My xplanation: Single element can be inserted in BST in O(log n) So inserting n elements would be n * O(log n) -- O(n log n) So as per me

Re: [algogeeks] Announcing ITRIX OPC 2011

2011-03-27 Thread Kunal Patil
How to solve that Lucky Sequence Again problem... i tried it using vectors...for small values it succeeded.. but it wasn't calculating for 10^10 or for large condition.. So what was the logic to solve the problem ??? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Coding Round

2011-03-26 Thread Kunal Patil
Yes...Kunal is right !!! It doesn't matter whether getMax() removes element or not, because MAX value is maintained in each node of stack which is pointing to the maximum of the value present below or up to that element... So if stack is 5 3 2 8 6 Then nodes would have following structure 5

Re: [algogeeks] Re: 23march

2011-03-23 Thread Kunal Patil
@dave: Very nice answer yaar..Excellent !!! On Wed, Mar 23, 2011 at 7:08 PM, Dave dave_and_da...@juno.com wrote: It is LCM(2,3,4,5,6,7,8,9,10) - 1 = 2^3 * 3^2 * 5 * 7 - 1 = 2519. LCM = least common multiple. Dave On Mar 23, 2:41 am, Lavesh Rawat lavesh.ra...@gmail.com wrote: *A

Re: [algogeeks] Re: power of 2

2011-03-20 Thread Kunal Patil
@cegprakash: y dont u use formula... log2(n) -- log(n) / log(2) -- 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

Re: [algogeeks] Re: Look and say sequence

2011-03-19 Thread Kunal Patil
Yes... See first num is 1 second is 11 (there is 1 number of 1 in previous number i.e. in 1) third is 21 (there is 2 number of 1 in previous number i.e. in 11) fourth is 1211 (there is 1 number of 2 and 1 number of 1 in previous number i.e. in 21) ans so on... Hope u got it -- You received this

Re: [algogeeks] Re: Look and say sequence

2011-03-19 Thread Kunal Patil
Nopes...why precalculate and waste space...+ It gets bigger n bigger afterwards Look at this algorithm.. en.wikipedia.org/wiki/Run-length_encoding -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: 10 digit problem

2011-03-18 Thread Kunal Patil
@Gunjan Sharma: Why do you think 50 is not an acceptable answer??? You might be thinking last 5 zeroes not representing the number of zeroes followed..thus you gave an answer as 10 in one of your previous post... But as per the problem is exemplified, *if it is the original precise

Re: [algogeeks] [brain teaser ] 18march

2011-03-18 Thread Kunal Patil
Nothing !!! :P :P On Fri, Mar 18, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *A Riddle Problem Solution* * *What is one thing that all wise men, regardless of their religion or politics, agree is between heaven and earth Update Your Answers at : Click

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-18 Thread Kunal Patil
Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find flaw in code... When i read your mail and corresponding sorry mail...it just struck me..I also had to print YES and NOand i was printing NO as NoIt got ac den... :P thnx

Re: [algogeeks] [brain teaser ] 15march

2011-03-18 Thread Kunal Patil
@ ashu:---Very interesting and nice solution... On Tue, Mar 15, 2011 at 2:58 PM, Terence technic@gmail.com wrote: To the east shop :) One can not get his haircut by himself. On 2011-3-15 15:55, Lavesh Rawat wrote: * barbershop **Problem Solution* * *A traveller arrives in a small

  1   2   >