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

2011-05-27 Thread Aakash Johari
Following code works for [A-Za-z], can be extended for whole character-set : > #include > > int main() > { > unsigned long long int a = 0; > char str[50]; > int i; > > scanf ("%s", str); > > for ( i = 0; str[i]; i++ ) { > if ( str[i] >= 'A' && str[i] <= 'Z' ) { >

[algogeeks] Re: posix threads

2011-05-27 Thread Adarsh
In Linux, there is no difference between threads and process. It is like, a thread is merely a process that shares certain resources with other processes. Each thread has its own process descriptor and appears to kernel as a normal process - threads just happen to share resources, such as an addres

[algogeeks] Re: Google Interview Question

2011-05-27 Thread Dumanshu
I think he means to edit the comparison function to get the order. so at a time only 2 elements are compared. On May 28, 7:51 am, Logic King wrote: > @sunny it will work fine if you have 2 numbers only...but what about the > list...3..4 or 5..or morethen the possible number of combinations wi

[algogeeks] Sudoku verification problem

2011-05-27 Thread Dumanshu
Given a n by n matrix. Suggest an algorithm to verify its correctness given a configuration. User can enter numbers only between 1 to n. I need this in 2 ways - 1. for the n by n matrix, suggest an elegant way for validating it. 2. suggest a data structure for this sudoku so that the structure aids

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

2011-05-27 Thread saurabh singh
string getStringWithoutDuplicateChars(string input) { create_empty_trie_ds (say trie) integer count = 0; for_each_char_in_string (say ch) { if(trie->contains(ch)) //if ch not there in ds then add it and return false otherwise return true { input.remove(count) } count++

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

2011-05-27 Thread Rajeev Kumar
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not. -- Thank You Rajeev Kumar -- You received this message because you are subscribed to the G

Re: [algogeeks] Re: sum of two

2011-05-27 Thread Aakash Johari
@Dave: I have suggested another solution in previous threads. Please go through that. That is without maps. It uses array for mapping. On Fri, May 27, 2011 at 10:09 PM, Dave wrote: > If map insertion is O(log n), then the algorithms that insert each > element into the map will be O(n log n), but

[algogeeks] Re: sum of two

2011-05-27 Thread Dave
If map insertion is O(log n), then the algorithms that insert each element into the map will be O(n log n), but the problem statement insists that we find two elements of the array that sum to a given number in O(n) time. Thus, Aakash's solution (http://groups.google.com/ group/algogeeks/msg/541180

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread Logic King
@ross i can do it in O(n) time using an extra array of the same size as the given array first sort both the even indexed terms and odd indexed terms by modifying quick sort...it can be done in one traversal. and then using extra array and then move the even indexed terms followed by odd index

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
ya .. it can work for negative indexes also if the bound is known.. like if the range is from -10 to +10 then declare an array of 20 and then refer a[10] as a[0] and use negative indexes to do the same procedure !! On Fri, May 27, 2011 at 2:32 PM, bhavana wrote: > hey...bt this one works only in

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread saurabh singh
Yup...I think thats the way to go...modify heap sort...'ignoring the odd childs' for ascending and ignoring the even child for decending. If i am wrong in this then quick sort has to be the solution. On Sat, May 28, 2011 at 8:44 AM, subramania jeeva wrote: > I hope merge sort is not an inplace so

Re: [algogeeks] ms ques

2011-05-27 Thread Logic King
http://samples.msdn.microsoft.com/ietestcenter/ On Fri, May 27, 2011 at 9:40 AM, radha krishnan < radhakrishnance...@gmail.com> wrote: > Check whether this is storing Google Search Results ? ? ?? ? ? ? ? ?? > [HONEY POTTING] > > > On Fri, May 27, 2011 at 10:07 PM, UTKARSH SRIVASTAV < > usrivas

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread subramania jeeva
I hope merge sort is not an inplace sorting.. It'll take extra space (in function merge) and since it uses recursion it'll also take stack space.. I think this sol will work. 1. partition the array by holding the even elements on first space(n/2 or n/2-1 depends on odd sized and even sized array)

Re: [algogeeks] Re: Google Interview Question

2011-05-27 Thread Logic King
@sunny it will work fine if you have 2 numbers only...but what about the list...3..4 or 5..or morethen the possible number of combinations will be 'N!'...where n is the number of digits...the code will work quite slowly for larger 'n'. On Fri, May 27, 2011 at 3:33 PM, Dave wrote: > @Shu

[algogeeks] Re: Google Interview Question

2011-05-27 Thread Dave
@Shubham: Try 8, 89, 7. Your algorithm gives 8897, but the right answer is 8987. Dave On May 27, 1:11 pm, shubham wrote: > check whether these steps work: > > step 1: >         sort the given numbers in the decreasing order based on their first > digit. > step 2: >         if two numbers come ou

Re: [algogeeks] Google Interview Question

2011-05-27 Thread sunny agrawal
will it work modifying the comparison function of the sort as follows generate two new numbers c and d from arguments a,b as c = ab; //concatenation d = ba; compare c and d if c >= d return true means a will come before b in final ordering else return false means b will come before in final order

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread Piyush Sinha
how large n will be...O(n) can't grow more than O(nlogn)so in any case the complexity is going to be O(nlogn)..so i dnt see any point of bringing our any modification of mergersort...even if u think so, provide a concrete algo On 5/28/11, LALIT SHARMA wrote: > It will give correct answer , >

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread LALIT SHARMA
It will give correct answer , but instead of doing manipulation after taking input. as it would take some O(n) time. if n would be large , we would incur this extra cost . we should change the termination condition of merge-sort function and modify the merge function of merge sort ..to reach our o

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread Piyush Sinha
main() { int a[100]; int i,j,N; printf("enter the number of elements: "); scanf("%d",&N); for(i=0;i wrote: > wat about insertion sort (with some limited conditions obviously ) ?? > > On Sat, May 28, 2011 at 12:56 AM, Piyush Sinha > wrote: > >> will it be given th

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread srajan dongre
wat about insertion sort (with some limited conditions obviously ) ?? On Sat, May 28, 2011 at 12:56 AM, Piyush Sinha wrote: > will it be given that the number of elements is always even?? > > On 5/28/11, ross wrote: > > Hi all, > > > > Sort all elements in odd indices of an array in ascending o

Re: [algogeeks] posix threads

2011-05-27 Thread LALIT SHARMA
@J, I think you are wrong about the thread scheduling on multiple cores , As one of the basic mapping technique would be used to map user level thread to kernel thread , one to one or many to many would serve the purpose . the point it that , you cant control how it would be mapped to a kernel thre

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread Piyush Sinha
will it be given that the number of elements is always even?? On 5/28/11, ross wrote: > Hi all, > > Sort all elements in odd indices of an array in ascending order and > even indices in descending order. > Finally, rearrange so that all even indexed elements come first. > > eg: > > input – 7 2 6

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@srajan: ya , i made a mistake...the correct ans will of-course be 9978 On Fri, May 27, 2011 at 12:11 PM, srajan dongre wrote: > @ankit sambyal.i think d rite answer will be 9978 in dat case. > > > > > On Fri, May 27, 2011 at 11:50 PM, ankit sambyal wrote: > >> @shubam: won't work

Re: [algogeeks] posix threads

2011-05-27 Thread Douglas Diniz
Whats the point? There is infinite points to use threads, even in a single core. On Fri, May 27, 2011 at 4:05 PM, jagannath wrote: > hi guys, >       i know that pthread is an user-level thread and an user-level > can't take the advantage of SMP. Then what is the point of creating > user-level th

Re: [algogeeks] Google Interview Question

2011-05-27 Thread srajan dongre
@ankit sambyal.i think d rite answer will be 9978 in dat case. On Fri, May 27, 2011 at 11:50 PM, ankit sambyal wrote: > @shubam: won't work >try following test case: 8,89,9 > > Ankit Sambyal > > > > On Fri, May 27, 2011 at 11:11 AM, shubham wrote: > >> check whether these steps wo

[algogeeks] posix threads

2011-05-27 Thread jagannath
hi guys, i know that pthread is an user-level thread and an user-level can't take the advantage of SMP. Then what is the point of creating user-level threads if they can't be scheduled on multiple cores?Please clear my doubt which has been hitting me for long... -- You received this me

[algogeeks] Re: Puzzle

2011-05-27 Thread Don
To solve this, look at an 8x8 grid representing the games played. The diagonal is not used, because teams do not play themselves. Below the diagonal is the first game between each team and above the diagonal is the second game. Assume that teams 1-4 are the ones who will go to the semi-finals. This

[algogeeks] Odd Even Sort array

2011-05-27 Thread ross
Hi all, Sort all elements in odd indices of an array in ascending order and even indices in descending order. Finally, rearrange so that all even indexed elements come first. eg: input – 7 2 6 4 8 3 1 even indexed : 7 6 8 1 => sort 8 7 6 1 odd indexed: 2 4 3 => sort 2 3 4 output – 8 7 6 1 2 3

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@shubam: won't work try following test case: 8,89,9 Ankit Sambyal On Fri, May 27, 2011 at 11:11 AM, shubham wrote: > check whether these steps work: > > step 1: > sort the given numbers in the decreasing order based on their first > digit. > step 2: > if two numbers come o

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@shubham, 10 101 ?? On Fri, May 27, 2011 at 11:41 PM, shubham wrote: > check whether these steps work: > > step 1: > sort the given numbers in the decreasing order based on their first > digit. > step 2: > if two numbers come out to be equal in the above case & both of > their ne

Re: [algogeeks] Google Interview Question

2011-05-27 Thread shubham
check whether these steps work: step 1: sort the given numbers in the decreasing order based on their first digit. step 2: if two numbers come out to be equal in the above case & both of their next digit exist then sort on the basis of their next digit, otherwise the number

Re: [algogeeks] Google Interview Question

2011-05-27 Thread ankit sambyal
@Piyush: try 97,8,9 acc. to ur algo, adding 0s: 97,80,90 then sorting : 97,90,80 so final ans acc. to ur algo: 9798 whereas the correct ans is : 9897 Ankit BITS Pilani On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > how about adding zeroes at the end of integers to make to equal to

[algogeeks] Re: Puzzle

2011-05-27 Thread L
Ah! sorry. This combination is not possible. It will be 10,10,10,10,10,4,2,0. So, the answer is 11. On May 27, 10:10 pm, L wrote: > The worst case will occur when 5 teams have the same number of wins. > As only 4 can qualify, one team with the same number of points will > not be able to qualify.

[algogeeks] Immediate requirement for Sr IBM Cognos Technical Architect // Raleigh, NC

2011-05-27 Thread Prakash recruiter
Dear Folks, Wishes for the Day, We need consultant for *Sr IBM Cognos Technical Architect* please share suitable profiles to prak...@panzersolutions.com *Job title : Sr IBM Cognos Technical Architect* *Location : Raleigh, NC * *Duration : 12 month * *Rate : Market * Job Responsibilities:

[algogeeks] Re: Puzzle

2011-05-27 Thread L
The worst case will occur when 5 teams have the same number of wins. As only 4 can qualify, one team with the same number of points will not be able to qualify. 1. 11 2. 11 3. 11 4. 11 5. 11 6. 1 7. 0 8. 0 In this scenario, a team with 11 points will not be able to qualify. So, to ensure that i

[algogeeks] ATG Developer // Vernon Hills, IL // 12 Months contract

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. *Please reply at soh...@panzersolutions.com * Title

Re: [algogeeks] ms ques

2011-05-27 Thread radha krishnan
Check whether this is storing Google Search Results ? ? ?? ? ? ? ? ?? [HONEY POTTING] On Fri, May 27, 2011 at 10:07 PM, UTKARSH SRIVASTAV wrote: > test cases for internet explorer > > -- > *UTKARSH SRIVASTAV > CSE-3 > B-Tech 2nd Year > @MNNIT ALLAHABAD* > > -- > You received this message beca

[algogeeks] ms ques

2011-05-27 Thread UTKARSH SRIVASTAV
test cases for internet explorer -- *UTKARSH SRIVASTAV CSE-3 B-Tech 2nd Year @MNNIT ALLAHABAD* -- 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,

[algogeeks] Lotus Connections Developer // Wilmington, DE // 6 Months contract

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. *Please reply at soh...@panzersolutions.com ** * Title

[algogeeks] Re: Google Interview Question

2011-05-27 Thread xeron!x
No, Kadane's algorithm considers subarray sum, we are considering concatenation ( for whole array ). The solution with custom string comparator : http://ideone.com/doASH. On May 27, 9:15 pm, Supraja Jayakumar wrote: > Hi > > Isnt this the Kadane's (largest subarray) problem ? > > Rgds > Supraja J

[algogeeks] 100% close for UI Developer in Chicago, IL

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. *Please reply at soh...@panzersolutions.com* * * Title

[algogeeks] Documentum Need // Nashville, TN // Open ended(Long Term)

2011-05-27 Thread sohail panzer
Dear Professional, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. * Please reply at soh...@panzersolutions.co

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
Kadane's algorithm is considers subarray sum, we are considering concatenation here. On Fri, May 27, 2011 at 9:45 PM, Supraja Jayakumar wrote: > Hi > > Isnt this the Kadane's (largest subarray) problem ? > > Rgds > Supraja J > > On Fri, May 27, 2011 at 9:41 AM, anshu mishra > wrote: > >> @all g

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Supraja Jayakumar
Hi Isnt this the Kadane's (largest subarray) problem ? Rgds Supraja J On Fri, May 27, 2011 at 9:41 AM, anshu mishra wrote: > @all go through this code > > #include > #include > > using namespace std; > bool compare(int a, int b) > { > string u, v; > u = v = ""; > while (

[algogeeks] Weblogic Portal Developer -- BASKING RIDGE, NJ -- 2 months contract

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. *Please reply at soh...@panzersolutions.com * Title

[algogeeks] island puzzle

2011-05-27 Thread himanshu kansal
a king has two sons eric and bob.he wants to divide his islands the islands are in a queue.eric being elder gets the first chancethey both can pick d island alternatively from beginning or end of the queue only.design an algo so tht eric gets the max. piece of land. i hv sol

[algogeeks] Immediate Need for Sharepoint/.NET Developer in Denver CO

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. Please reply at soh...@panzersolutions.com Title

Re: [algogeeks] Google Interview Question

2011-05-27 Thread anshu mishra
@all go through this code #include #include using namespace std; bool compare(int a, int b) { string u, v; u = v = ""; while (a) { u += (a % 10 + '0'); a/=10; } while (b) { v += (b % 10 + '0');

[algogeeks] Sure Shot Closure for Perl Programmer in Ft. Lauderdale, FL

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. * Please reply at soh...@panzersolutions.com * Title

[algogeeks] Senior Network Admin // Boston, MA // 6+ Months contract

2011-05-27 Thread sohail panzer
Hello, Hope you are doing well. I am a technical recruiter with Panzer Solutions LLC Software Implementing and IT consulting company located in CT. Please go through the Job Description and send me your updated resume with contact information. Title : Senior Network Admi

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Arpit Mittal
@vishwakarma thanks for rectifying me... its clear... 12 is not posible, i was in another way :) On Fri, May 27, 2011 at 7:46 AM, vishwakarma wrote: > correction---it was typo mistake ... > Team C loses to(one to A and one to B) > > On May 27, 7:44 pm, vishwakarma wrote: > > so here we go

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
correction-->>"Then C loses two of its matches to(one to A and one to C). " to "Then C loses two of its matches to(one to A and one to B) ". On May 27, 7:44 pm, vishwakarma wrote: > so here we go > > Let A loses two of its matches to (one to B and one to C). > Let B loses two of its matches

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
correction---it was typo mistake ... Team C loses to(one to A and one to B) On May 27, 7:44 pm, vishwakarma wrote: > so here we go > > Let A loses two of its matches to (one to B and one to C). > Let B loses two of its matches to(one to A and one to C) > Then C loses two of its matches to(o

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
so here we go Let A loses two of its matches to (one to B and one to C). Let B loses two of its matches to(one to A and one to C) Then C loses two of its matches to(one to A and one to C). Now. team D, if it ever plays with (A,B,C) will loses..hence minimum number o matches it is going to

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@Aakash, yeah missed that, overriding default string comparator while sorting will do that. On Fri, May 27, 2011 at 8:11 PM, Arpit Mittal wrote: > @piyush : > > for 1, 100 > > you did > 100,100 > then sort > result 100,100 > > so u said ans is 1100 but it could also be 1001 as 100=100... > > co

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Arpit Mittal
@piyush : for 1, 100 you did 100,100 then sort result 100,100 so u said ans is 1100 but it could also be 1001 as 100=100... correct me if i am wrong? On Fri, May 27, 2011 at 7:39 AM, Aakash Johari wrote: > @vipul: try for 100 and 10 > > > 2011/5/27 • » νιρυℓ « • > >> @Piyush Sinha, >> what

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Aakash Johari
@vipul: try for 100 and 10 2011/5/27 • » νιρυℓ « • > @Piyush Sinha, > what about 9, 801 > > 2011/5/27 • » νιρυℓ « • > >> Take input as vector of string or array of string >> sort the vector >> print from end to beginning >> >> >> On Fri, May 27, 2011 at 7:51 PM, Logic King >> wrote: >> >>> i

Re: [algogeeks] one constructor problem

2011-05-27 Thread Logic King
@D.N. I Think if you removes default constructor and give only parametrized constructor...then it i going to give any errorit should work fine.. On Fri, May 27, 2011 at 4:40 AM, Aakash Johari wrote: > Provide some default value to the parameterized constructor. > * > A(int m = 0) { >

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
@Piyush Sinha, what about 9, 801 2011/5/27 • » νιρυℓ « • > Take input as vector of string or array of string > sort the vector > print from end to beginning > > > On Fri, May 27, 2011 at 7:51 PM, Logic King wrote: > >> i agree with piyush...can't find the countercase...satisfied with the >> alg

[algogeeks] Immediate requirements for Peoplesoft Developer // wilmington,DE

2011-05-27 Thread Prakash recruiter
Dear Folks, Wishes for the Day, We need consultant for *PeopleSoft Developer* please share suitable profiles to prak...@panzersolutions.com *Job title: PeopleSoft Developer* *Location : Wilmington, DE * *Duration : 6 Months* *Rate: Market * Job Responsibilities: Participate in

Re: [algogeeks] Google Interview Question

2011-05-27 Thread • » νιρυℓ « •
Take input as vector of string or array of string sort the vector print from end to beginning On Fri, May 27, 2011 at 7:51 PM, Logic King wrote: > i agree with piyush...can't find the countercase...satisfied with the algo. > > > On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > >> how about

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Arpit Mittal
@Vishwakarma it is now ok that 11 should be the answer, but why any 4 teams cannot win 12 matches in total... for that they have to score 12*4 = 48 points out of 56. then wats the problem. i know how it is coming 11 now, but i am replying back for the doubt i have in a line u just mentioned in y

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Arpit Mittal
@rishabh : now i understand it better... thanks :) On Fri, May 27, 2011 at 7:22 AM, Rishabh Maurya wrote: > because we want upper 4 teams to win maximum matches altogether so > to satisfy this criteria .. last team should win 0 , and team 7 must have > lost all its matches except from t

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
@Arpit Any four team cannot win 12 matches in total. ...Rishabh is wid right answer that is ( " 11 " ). Hence any team winning its any 11 out of 14 matches ensures its entry to semis. But not below 11 its entry to semi will depend on other team performance. On May 27, 7:11 pm, Arpit Mittal

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Logic King
i agree with piyush...can't find the countercase...satisfied with the algo. On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha wrote: > how about adding zeroes at the end of integers to make to equal to the > integer with maximum number of digits and sort them... > > ex- > 101 10 > > adding zeroes.. >

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Rishabh Maurya
because we want upper 4 teams to win maximum matches altogether so to satisfy this criteria .. last team should win 0 , and team 7 must have lost all its matches except from team 8 , so it wins 2 and similarly team 6 wins 4 and team 5 wins 6 . don't forget to watch MI vs RCB .. :) --

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
sorry !!! correction-->>..i misread the problem My solution gives "what is the lowest possible number of matches won by a qualifying team ". On May 27, 6:37 pm, vishwakarma wrote: > Correct me if i m wrong !!! > > Number of matches of each team  = 14. > Let team A,B,C,D qualify for semifinal. > 1

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Arpit Mittal
@rishabh : in your solution u have taken scores of last 4 teams as 6 4 2 0. what if i take 2 2 2 2 then the ans would be 56-(2+2+2+2)/4 = 12...!!! and i can also take the scores of last 4 teams as 6 4 4 2 then the ans would be 56-(6+4+4+2)/4 = 10!!! so how you can say it would be 11? On Fri,

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Piyush Sinha
how about adding zeroes at the end of integers to make to equal to the integer with maximum number of digits and sort them... ex- 101 10 adding zeroes.. 101 100 sort 100 101 therefore make number as 10110 100 1 adding zeroes 100 100 therefore number is 1100 I am not sure of the method.i

Re: [algogeeks] Re: Puzzle

2011-05-27 Thread Rishabh Maurya
No , you are wrong .. problem statement says how many matches should a teams win to ensure its qualification , their no word like minimum or maximum ... 8 gets wrong if following situation arises 1 -> 9 2 -> 9 3 -> 9 4 -> 9 5 -> 8 6 -> 6 7 -> 4 8 -> 2 -- You received this message because you

Re: [algogeeks] Google Interview Question

2011-05-27 Thread wujin chen
@radha, i think your solution is wrong. for this case: 101,10 in your solution , the ans is 10101,but the max ans is 10110. 2011/5/27 radha krishnan > 10100 is max ans > okay > convert the numbers to strings and sort based on the first character > !!! > if equal do that recursively and the

Re: [algogeeks] Google Interview Question

2011-05-27 Thread adityasirohi
how about this case: 9, 100 -> 9100 100 9 9100 2, 3, 9, 78 --> 78 9 3 2 9 78 3 2 I guess solution should be:- sort the array of numbers in an ascending order and then check for the first element in the array, if there is any other element greater than it, shift all the elements one right and

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
10100 is max ans okay convert the numbers to strings and sort based on the first character !!! if equal do that recursively and then if length is less give that preference !! i think this solution .. may be this is wrong !! On Fri, May 27, 2011 at 7:07 PM, wujin chen wrote: > @Piyush, how t

Re: [algogeeks] Google Interview Question

2011-05-27 Thread wujin chen
@Piyush, how to deal with this case :100 , 10 2011/5/27 Piyush Sinha > we can work out if we sort according to the leftmost integer > > On 5/27/11, adityasir...@gmail.com wrote: > > are you kidding me. Just simple sort wont work. > > > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > > rad

[algogeeks] Re: Puzzle

2011-05-27 Thread vishwakarma
Correct me if i m wrong !!! Number of matches of each team = 14. Let team A,B,C,D qualify for semifinal. 1.maximum number of matches A can win = 14 (all played ) 2.maximum number of matches B can win = 12 (all played except played with team A) 3.maximum number of matches C can win = 10 (all play

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
Haha !! Any counter case against sort ? ?? ? :P On Fri, May 27, 2011 at 7:02 PM, wrote: > are you kidding me. Just simple sort wont work. > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > radhakrishnance...@gmail.com> wrote: > >> sort :) >> >> >> On Fri, May 27, 2011 at 6:57 PM, ross wro

Re: [algogeeks] Google Interview Question

2011-05-27 Thread Piyush Sinha
we can work out if we sort according to the leftmost integer On 5/27/11, adityasir...@gmail.com wrote: > are you kidding me. Just simple sort wont work. > > On Fri, May 27, 2011 at 9:31 AM, radha krishnan < > radhakrishnance...@gmail.com> wrote: > >> sort :) >> >> >> On Fri, May 27, 2011 at 6:57

Re: [algogeeks] Google Interview Question

2011-05-27 Thread adityasirohi
are you kidding me. Just simple sort wont work. On Fri, May 27, 2011 at 9:31 AM, radha krishnan < radhakrishnance...@gmail.com> wrote: > sort :) > > > On Fri, May 27, 2011 at 6:57 PM, ross wrote: > >> Hi all, >> >> Given an array of elements find the largest possible number that can >> be formed

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
sort :) On Fri, May 27, 2011 at 6:57 PM, ross wrote: > Hi all, > > Given an array of elements find the largest possible number that can > be formed by using the elements of the array. > > eg: 10 9 > ans: 910 > > 2 3 5 78 > > ans: 78532 > > 100 9 > > ans: 9100 > > -- > You received this message b

[algogeeks] Google Interview Question

2011-05-27 Thread ross
Hi all, Given an array of elements find the largest possible number that can be formed by using the elements of the array. eg: 10 9 ans: 910 2 3 5 78 ans: 78532 100 9 ans: 9100 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

Re: [algogeeks] Puzzle

2011-05-27 Thread Aakash Johari
Is it the minimum required matches to ensure for semifinals? On Fri, May 27, 2011 at 6:06 AM, Rishabh Maurya wrote: > suppose bottom 4 teams have won least matches and upper 4 teams have won > equal number of matches ... > > 1 -> x > 2 -> x > 3 -> x > 4 -> x > > 5 -> 6 > 6 -> 4 > 7 -> 2 > 8 ->

Re: [algogeeks] Puzzle

2011-05-27 Thread Rishabh Maurya
suppose bottom 4 teams have won least matches and upper 4 teams have won equal number of matches ... 1 -> x 2 -> x 3 -> x 4 -> x 5 -> 6 6 -> 4 7 -> 2 8 -> 0 total matches are 56 and let upper four teams have won x matches each so x = (56-(6+4+2+0))/4 x = 11 so in this way to ensure qualific

Re: [algogeeks] Puzzle

2011-05-27 Thread Arpit Mittal
could you please explain how? On Fri, May 27, 2011 at 3:45 AM, varun pahwa wrote: > i think 11. > > On Fri, May 27, 2011 at 3:06 PM, Arpit Mittal wrote: > >> 8? >> >> >> On Fri, May 27, 2011 at 2:26 AM, anil chopra >> wrote: >> >>> 11 >>> >>> On Fri, May 13, 2011 at 12:14 AM, amit wrote: >>> >>

Re: [algogeeks] one constructor problem

2011-05-27 Thread Aakash Johari
Provide some default value to the parameterized constructor. * A(int m = 0) { a = m; } * On Fri, May 27, 2011 at 4:36 AM, D.N.Vishwakarma@IITR wrote: > without default constructor what will be solution > > On Wed, May 25, 2011 at 10:56 AM, Aakash Johari wrote: > >> This way you can do: >>

Re: [algogeeks] one constructor problem

2011-05-27 Thread D.N.Vishwakarma@IITR
without default constructor what will be solution On Wed, May 25, 2011 at 10:56 AM, Aakash Johari wrote: > This way you can do: > > #include > > using namespace std; > > class A { > public: > int a; > > A(int m) { > a = m; >

Re: [algogeeks] Re: strings

2011-05-27 Thread Aakash Johari
Can be solved in this way also : > #include > #include > > using namespace std; > > string a, b, c; > int memo[51][51][51]; > > int interleave(int ai, int bi, int ci) > { > int r1, r2; > > r1 = r2 = 0; > > if ( ai == a.size() && bi == b.size() && ci == c.size() ) { > return 1

Re: [algogeeks] Puzzle

2011-05-27 Thread varun pahwa
i think 11. On Fri, May 27, 2011 at 3:06 PM, Arpit Mittal wrote: > 8? > > > On Fri, May 27, 2011 at 2:26 AM, anil chopra wrote: > >> 11 >> >> On Fri, May 13, 2011 at 12:14 AM, amit wrote: >> >>> Consider a series in which 8 teams are participating. each team plays >>> twice with all other teams.

Re: [algogeeks] Re: spoj--two squares problem

2011-05-27 Thread Balaji S
what if c=9.. 9%4=1 ryt? -- 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] Re: suitable data structure

2011-05-27 Thread Aakash Johari
In case of trie tree, you need not to traverse through the whole tree. Just look at how trie tree works, you will come to know. On Fri, May 27, 2011 at 2:27 AM, bhavana wrote: > sorry guys fr my last post...bcoz dis doesnt provide any benefit..in terms > of either space or time . > > > On Fri, M

Re: [algogeeks] Puzzle

2011-05-27 Thread Arpit Mittal
8? On Fri, May 27, 2011 at 2:26 AM, anil chopra wrote: > 11 > > On Fri, May 13, 2011 at 12:14 AM, amit wrote: > >> Consider a series in which 8 teams are participating. each team plays >> twice with all other teams. 4 of them will go to the semi final.How >> many matches should a team win, so th

Re: [algogeeks] Re: suitable data structure

2011-05-27 Thread bhavana
sorry guys fr my last post...bcoz dis doesnt provide any benefit..in terms of either space or time . On Fri, May 27, 2011 at 2:55 PM, bhavana wrote: > @himanshu : den do map the wrong words as u go on finding them in the doc. > > > On Fri, May 27, 2011 at 2:51 PM, himanshu kansal < > himanshukan

Re: [algogeeks] Puzzle

2011-05-27 Thread anil chopra
11 On Fri, May 13, 2011 at 12:14 AM, amit wrote: > Consider a series in which 8 teams are participating. each team plays > twice with all other teams. 4 of them will go to the semi final.How > many matches should a team win, so that it will ensure that it will go > to semi finals.? > > -- > You

Re: [algogeeks] Re: suitable data structure

2011-05-27 Thread bhavana
@himanshu : den do map the wrong words as u go on finding them in the doc. On Fri, May 27, 2011 at 2:51 PM, himanshu kansal < himanshukansal...@gmail.com> wrote: > thnks shashankbt i hv used trie for building the dictionary..bt > since d wrong words does nt hv a common prefix...so it is

Re: [algogeeks] Re: suitable data structure

2011-05-27 Thread himanshu kansal
thnks shashankbt i hv used trie for building the dictionary..bt since d wrong words does nt hv a common prefix...so it is nt suitable for storing wrong words(worst case scenario is common)... so i need a ds tht wd make d search of wrong words faster.nd v dont hv to scan d entire diction

Re: [algogeeks] Re: sum of two

2011-05-27 Thread Aakash Johari
In the second approach I wrote to use array for mapping > "you can simply map the existence/non-existence of any particular element > in an array. that will be in constant time (for query purposes) and O(n) > time for preprocessing." > > On Fri, May 27, 2011 at 2:18 AM, sukhmeet singh wrote: > a

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
actly i did.. but bhavana didn;t used STL ..!! My question to you was regarding Dave 's query which i didn't understand what he meant by saying : "@Aakash: And tell me how map works. Is making an entry O(1) regardless of the value of the entry? For example, is it O(n) to map the sequence 1, 4, 9,

Re: [algogeeks] Re: sum of two

2011-05-27 Thread Aakash Johari
@sukhmeet: could you get my approach? it was same as Bhavana explained. On Fri, May 27, 2011 at 2:12 AM, bhavana wrote: > hehe...d difference is regarding time complexity...bcoz map takes 0(logN) > for insertion while array can b accessed in constant time through index. > > > On Fri, May 27, 201

Re: [algogeeks] Re: sum of two

2011-05-27 Thread bhavana
hehe...d difference is regarding time complexity...bcoz map takes 0(logN) for insertion while array can b accessed in constant time through index. On Fri, May 27, 2011 at 2:39 PM, sukhmeet singh wrote: > k.. got it .. but it was same as putting them into a map ..if the bound 'b' > is not known..

Re: [algogeeks] output

2011-05-27 Thread • » νιρυℓ « •
Newline Character '\n' => ascii 10 On Fri, May 27, 2011 at 2:36 PM, Bhavesh agrawal wrote: > #include > /* copy input to output; 2nd version */ > main() > { > int c; > while ((c = getchar()) != EOF && printf("%d\n",c)) > {putchar(c); > printf("\n");} > } > > it's output is like > a > 97 > a > 1

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
k.. got it .. but it was same as putting them into a map ..if the bound 'b' is not known.. as said be Akash .. But if STL is not allowed your approach is mch better..Noogle.. also a simple change that can be done if the each number is that we can check if (sum - a[i] )!= i then getting same can b

  1   2   >