[algogeeks] Manufacturing equal length poles from given Rods
Hello geeks, I came across a problem, please help me to find out solution of it. Statement: There are N iron rods having some hight, task is to manufacture two poles having same hight using the available N rods. ( these poles are used for hoarding), it’s expected that hoarding can be seen from very far. Condition: two rods can join but we cant cut the rod.because cost of cutting is very high. It is not required to use all rods. If there is no solution return 0. Constraints: N is : 5<=N<=50 K is length of rod.: 1<=K<=1000 Maximum hight of poles can be 1000. Ex: N=6 K: 1 3 2 6 4 Sol: 1 3 4 pole1 6 2 Pole2 Thanks Pankaj -- Regards, Pankaj Kumar Joshi -- 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] variation of LIS problem
hi all, nlog(k) is the solution i think. can anyone suggest more optimal? solution: create a min-heap, (condition size should be always k) temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] delete root in min- heap inseart a[i] in min - heap at the end of main loop the min-heap will contain the final sequence. On Thu, Oct 24, 2013 at 8:50 AM, atul anand atul.87fri...@gmail.com wrote: @Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: Do you mean *of all the increasing subsequences of length k in this array, find the one with maximum sum ?* On Wed, Oct 23, 2013 at 10:52 PM, atul anand atul.87fri...@gmail.comwrote: Given an array with N elements and integer K . Find sum of longest increasing sub-sequence of length K elements such that sub-sequence found is maximum among all K max su-sequence. Eg arr[]={5,2,1,10,9,30,8,55} K = 3 output : 10,30,55sum = 10+30+55 = 95 if K=4 output : 5,10,30,55 sum = 5+10+30+55 =100 -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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. -- 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, Pankaj Kumar Joshi -- 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] variation of LIS problem
@ Saurabh, I have done a correction on algo temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] if min-heap(count)==k delete root in min- heap inseart a[i] in min - heap As i have made the condition: min-heap, (condition size should be always k) for this particular case. And in the example {5,2,1,10,9,30,8,55} if K =3 insert 5 2 is less so do nothing 1 is less so do nothing insert 10 9 is less so do nothing insert 30 8 is less so do nothing insert 55 (before inserting 50 delete the root of heap as count of heap == 3), deleted root was - 5 so the output will be {10,30,55} and if k is 4 than {5, 10, 30 , 55) On Thu, Oct 24, 2013 at 6:20 PM, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: You must be mistaken in the definition of heaps, or maybe the question, look at the updated question I put up there. On Thu, Oct 24, 2013 at 5:48 PM, pankaj joshi joshi10...@gmail.comwrote: hi all, nlog(k) is the solution i think. can anyone suggest more optimal? solution: create a min-heap, (condition size should be always k) temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] delete root in min- heap inseart a[i] in min - heap at the end of main loop the min-heap will contain the final sequence. On Thu, Oct 24, 2013 at 8:50 AM, atul anand atul.87fri...@gmail.comwrote: @Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: Do you mean *of all the increasing subsequences of length k in this array, find the one with maximum sum ?* On Wed, Oct 23, 2013 at 10:52 PM, atul anand atul.87fri...@gmail.comwrote: Given an array with N elements and integer K . Find sum of longest increasing sub-sequence of length K elements such that sub-sequence found is maximum among all K max su-sequence. Eg arr[]={5,2,1,10,9,30,8,55} K = 3 output : 10,30,55sum = 10+30+55 = 95 if K=4 output : 5,10,30,55 sum = 5+10+30+55 =100 -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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. -- 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, Pankaj Kumar Joshi -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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, Pankaj Kumar Joshi -- 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] variation of LIS problem
@Saurabh: As per the question the elements of sub-sequence should be increasing, so the solution will be {5} and as per the program. * but as written longest sub-sequence of k =2, so it should be {2,3} for this case. (there should be backtrack in this case.) @atul: increasing sub sequence is checked by condition, not by Min-heap, but min heap is used for storing the largest elements. So it is preferable DS, On Thu, Oct 24, 2013 at 8:35 PM, atul anand atul.87fri...@gmail.com wrote: @pankaj : how can you maintain increasing sub-sequence using heapyour soln is for finding finding K largest element in the array...so it wont work. On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: check for {5,2,3} and K = 2. On Thu, Oct 24, 2013 at 7:41 PM, pankaj joshi joshi10...@gmail.com wrote: @ Saurabh, I have done a correction on algo temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] if min-heap(count)==k delete root in min- heap inseart a[i] in min - heap As i have made the condition: min-heap, (condition size should be always k) for this particular case. And in the example {5,2,1,10,9,30,8,55} if K =3 insert 5 2 is less so do nothing 1 is less so do nothing insert 10 9 is less so do nothing insert 30 8 is less so do nothing insert 55 (before inserting 50 delete the root of heap as count of heap == 3), deleted root was - 5 so the output will be {10,30,55} and if k is 4 than {5, 10, 30 , 55) On Thu, Oct 24, 2013 at 6:20 PM, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: You must be mistaken in the definition of heaps, or maybe the question, look at the updated question I put up there. On Thu, Oct 24, 2013 at 5:48 PM, pankaj joshi joshi10...@gmail.comwrote: hi all, nlog(k) is the solution i think. can anyone suggest more optimal? solution: create a min-heap, (condition size should be always k) temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] delete root in min- heap inseart a[i] in min - heap at the end of main loop the min-heap will contain the final sequence. On Thu, Oct 24, 2013 at 8:50 AM, atul anand atul.87fri...@gmail.comwrote: @Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: Do you mean *of all the increasing subsequences of length k in this array, find the one with maximum sum ?* On Wed, Oct 23, 2013 at 10:52 PM, atul anand atul.87fri...@gmail.comwrote: Given an array with N elements and integer K . Find sum of longest increasing sub-sequence of length K elements such that sub-sequence found is maximum among all K max su-sequence. Eg arr[]={5,2,1,10,9,30,8,55} K = 3 output : 10,30,55sum = 10+30+55 = 95 if K=4 output : 5,10,30,55 sum = 5+10+30+55 =100 -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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. -- 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, Pankaj Kumar Joshi -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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, Pankaj Kumar Joshi -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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
Re: [algogeeks] variation of LIS problem
Max-heap should not used in this case, why min heap? -- this is because program has to decide the smallest element in k-group. in your example if i consider k =3 than insert 1 insert 2 insert 5 insert 10 size of heap ==4 so delete root of min- heap (which is 1), insert 100 30 cant insert because temp = 100 and 30temp insert 8 cant insert temp = 100 and 8temp (500temp)size of heap ==4 so delete root of min-heap(which is 2) insert 555 now if i check the heap elements {5, 10, 100 , 555} On Thu, Oct 24, 2013 at 11:25 PM, atul anand atul.87fri...@gmail.comwrote: in your updated algo , you should be using max-heap not min-heap. check your algo for :- 1,2,5,10,100,30,8,555 let me know if it work fine.If it is working fine then i need more clarity of your algo On 10/24/13, pankaj joshi joshi10...@gmail.com wrote: @Saurabh: As per the question the elements of sub-sequence should be increasing, so the solution will be {5} and as per the program. * but as written longest sub-sequence of k =2, so it should be {2,3} for this case. (there should be backtrack in this case.) @atul: increasing sub sequence is checked by condition, not by Min-heap, but min heap is used for storing the largest elements. So it is preferable DS, On Thu, Oct 24, 2013 at 8:35 PM, atul anand atul.87fri...@gmail.com wrote: @pankaj : how can you maintain increasing sub-sequence using heapyour soln is for finding finding K largest element in the array...so it wont work. On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: check for {5,2,3} and K = 2. On Thu, Oct 24, 2013 at 7:41 PM, pankaj joshi joshi10...@gmail.com wrote: @ Saurabh, I have done a correction on algo temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] if min-heap(count)==k delete root in min- heap inseart a[i] in min - heap As i have made the condition: min-heap, (condition size should be always k) for this particular case. And in the example {5,2,1,10,9,30,8,55} if K =3 insert 5 2 is less so do nothing 1 is less so do nothing insert 10 9 is less so do nothing insert 30 8 is less so do nothing insert 55 (before inserting 50 delete the root of heap as count of heap == 3), deleted root was - 5 so the output will be {10,30,55} and if k is 4 than {5, 10, 30 , 55) On Thu, Oct 24, 2013 at 6:20 PM, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: You must be mistaken in the definition of heaps, or maybe the question, look at the updated question I put up there. On Thu, Oct 24, 2013 at 5:48 PM, pankaj joshi joshi10...@gmail.comwrote: hi all, nlog(k) is the solution i think. can anyone suggest more optimal? solution: create a min-heap, (condition size should be always k) temp =0 loop n to a[] if a[i]temp if min-heap(root) a[i] delete root in min- heap inseart a[i] in min - heap at the end of main loop the min-heap will contain the final sequence. On Thu, Oct 24, 2013 at 8:50 AM, atul anand atul.87fri...@gmail.comwrote: @Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: Do you mean *of all the increasing subsequences of length k in this array, find the one with maximum sum ?* On Wed, Oct 23, 2013 at 10:52 PM, atul anand atul.87fri...@gmail.comwrote: Given an array with N elements and integer K . Find sum of longest increasing sub-sequence of length K elements such that sub-sequence found is maximum among all K max su-sequence. Eg arr[]={5,2,1,10,9,30,8,55} K = 3 output : 10,30,55sum = 10+30+55 = 95 if K=4 output : 5,10,30,55 sum = 5+10+30+55 =100 -- 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. -- -Saurabh Paliwal B-Tech. Comp. Science and Engg. IIT ROORKEE -- 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. -- 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, Pankaj Kumar Joshi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from
[algogeeks] Need an optimized solution.
HI All, Puzzle: (This puzzle is of hacker rank) Harvey gives two numbers N and K and defines a set A. *A = { x : x is a natural numberhttps://en.wikipedia.org/wiki/Natural_number ≤ N }* (i.e), A = {1,2,3,4,5,6,…., N} Mike has to find the total number of pairs of elements A[i] and A[j] belonging to the given set such that i j and their sum is divisible by K Solution:- (I am facing a problem of time exceed. can you tell me an optimize solution) the complexity of below solution is O(M*N) {M is numbers and N is Div} static long Occurances(int Number, int Div) { long retVal = 0; for (int i = 1; i = Number; i++) { int cout = 1; int result = Div * cout - i; cout = (result 0) ? cout : i / Div; result = Div * cout - i; while (result = Number) { if (result i) { retVal++; } else { cout = 2 * i / Div; } cout++; result = Div * cout - i; } } return retVal; } Test conditions are, so take care of space also. K=N=109 1=K=1 Regards, Pankaj Kumar Joshi -- 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] Re: Array of intergers with repeating elements
Hi, we can calculate the frequency of all element, Assign sort them in increasing order of frequency. then the first element of sorted list will be the return element. 0bn we can implement it by Min Heap(which is based upon the frequency and reorganise itself as the frequency of element change (dynamically)). On Thu, May 9, 2013 at 12:41 AM, MAC macatad...@gmail.com wrote: sry link was not pasted http://stackoverflow.com/questions/7338070/finding-an-element-in-an-array-where-every-element-is-repeated-odd-number-of-tim thanks --mac On Thu, May 9, 2013 at 12:40 AM, MAC macatad...@gmail.com wrote: if one can explin me this i think this problem will get solved thanks --mac On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote: I was asked this in recent amazon onsite interview and asked o write code Given an Array of integers . N elements occur k times and one element occurs b times, in other words there are n+1 distinct Elements. Given that 0 b k find the element occurring b times. We know k is NOT even . thanks --mac -- 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, Pankaj Kumar Joshi -- 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] Re: Amazon interview question
an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Regards, Pankaj Kumar Joshi -- 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. For more options, visit https://groups.google.com/groups/opt_out.
[algogeeks] Re: Openings in Amazon
Sir, I have sent you my CV on vivekr...@gmail.com. Hope you got that On Friday, November 23, 2012 9:29:29 PM UTC+5:30, Vivek Ramamurthy wrote: Hi, Amazon is hiring people for software development projects undergoing at Blore, Hyd and Chennai divisions.There are openings for Software Development Engineer, Software Development Engineer in Test, Application Engineer and for Quality Assurance Engineer positions .Send me your resume if you are interested. -- *Vivek Ramamoorthy, *SDE, Amazon, Chennai. --
Re: [algogeeks] Re: amazon ques
same question as above with one more task is given 4) FindAnyElement() which will return any element present in that structure with O(1). for given all 4 task Please suggest which Data Structure is better now...? Best Regards, Pankaj Agarwal -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Suggest Algo: OffCampus Apple Interview Question
One approach could be using the file. Say x = 50 %, so every alternate run, the output should be true. 1. First run, store 0.5 in the file 2. Second run, add 0.5 to the previous value 3. Check if the sum is 1.d where 0 = d 1, return true and store 0.d in the file We can extend the same logic for any value of x. -- Pankaj On Wed, Nov 30, 2011 at 12:45 PM, atul anand atul.87fri...@gmail.comwrote: @nitin : as mentioned in the subject , its for Apple BTW @siddharth , i did not understand your question . little more explanation please. On Mon, Nov 28, 2011 at 7:14 PM, Nitin Garg nitin.garg.i...@gmail.comwrote: Please clarify. Also tell offcampus interview for which company? On Mon, Nov 28, 2011 at 7:10 PM, Siddharth Pipriya sid@gmail.comwrote: write a program that takes as input a number x and gives output true x percent of the time it is run. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nitin Garg Personality can open doors, but only Character can keep them open -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] AMDOCS
hii Any help or suggestions is greatly welcome for AMDOCS interview..i have gone through the archives but it was not much helpful. thanks in advance. Pankaj Saikia -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Directi Questions - needed answers
@Nitin Garg Question 6 - i agree that greater the sum is and greater the probability to getting it. but in given question if sum100 then rolling is stopped so for P(106)=P(100)*1/6 P(105)=P(100)*1/6+P(99)*1/6 . . . P(101)=P(100)*1/6+P(99)*(1/6)+P(98)*(1/6)+P(97)*(1/6)+..+P(95)*(1/6) now P(101) is more cleare me if something is wrong. On Mon, Sep 19, 2011 at 1:35 PM, Nitin Garg nitin.garg.i...@gmail.comwrote: Question 6 - Intuitively you can see that the greater the sum is, the greater the favorable events in sample space. e.g. - sum = 1 .. cases {(1)} Pr = 1/6 sum = 2 cases {(2),(1,1)} Pr = 1/6 + 1/36 sum = 3cases {(3),(2,1)(1,2)(1,1,1)} Pr = 1/6 + 1/36 +1/36 + 1/216 for a more formal proof, look at the recursion - P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6 where P(0) = 1, P(i) = 0 for i0 Base case - P(2) P(1) Hypothesis - P(i) P(i-1) for all i = k To prove P(k+1) P(k) Proof P(k+1) - P(k) = (P(k) - P(k-6))/6 0 -- Pankaj Agarwal Communication and Computer Engineering LNMIIT,jaipur -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] runtime error help
can any one help me why am i getting runtime error in the program. my program is def call(a,b): print(((pow(a,b))%10)); def main(): n=input(); for x in range(n): import sys a,b = map(long,sys.stdin.readline().split()); a=a%10; if((a==0)or(a==1)or(a==5)or(a==6)): print(a); if(a==2 or a==7 or a==8 or a==3): call(a,b%4) if(b==4 or b==9): call(a,b%2); main(); i am solving lastdig2 problem of spoj http://www.spoj.pl/problems/LASTDIG2/ -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] pankaj kumar wants to chat
--- pankaj kumar wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-fec58d8386-f16dcef73c-qIhM6BVo3OJNdgYKy2viERCQNpE You'll need to click this link to be able to chat with pankaj kumar. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with pankaj kumar, visit: http://mail.google.com/mail/a-fec58d8386-f16dcef73c-qIhM6BVo3OJNdgYKy2viERCQNpE Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Link list problem..
if doubly link list then it is possible to insert a new node before the current pointer. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me
5)program will compile and ans is 2 3 5 6 -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] amazon test question!!!
what's ans -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] OT- Latest C++ primer edition.
I have been trying to find it on net in *pdf* format but unsuccessful. Online bookstore link will do with reasonable rate :) or If anyone can share the pdf link. Cheers Pankaj -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Directi Question
There are two cases: First if we get even number in first roll. So P(A)= 1/2 And if We get odd number in second roll, then we need keep rolling untill we find another odd number. So, (1/2)*[1/2] + 1/2*1/2*1/2 upto infinity. On Sat, Aug 6, 2011 at 8:46 PM, Nitin Gupta gupta.nitingupta.ni...@gmail.com wrote: 1/6*5/6*5/6*3+ 1/6*1/6*5/6*3+ 1/6*1/6*1/6 =91/216 On Sat, Aug 6, 2011 at 8:24 PM, muthu raj muthura...@gmail.com wrote: Microsoft written: What is the probability of getting atleast one 6 in 3 attempts of a dice? *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sat, Aug 6, 2011 at 7:34 AM, shady sinv...@gmail.com wrote: Hi, A fair dice is rolled. Each time the value is noted and running sum is maintained. What is the expected number of runs needed so that the sum is even ? Can anyone tell how to solve this problem ? as well as other related problems of such sort -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Directi Question
Sorry, I mis understood the ques. On Sat, Aug 6, 2011 at 8:56 PM, Pankaj jatka.oppimi...@gmail.com wrote: There are two cases: First if we get even number in first roll. So P(A)= 1/2 And if We get odd number in second roll, then we need keep rolling untill we find another odd number. So, (1/2)*[1/2] + 1/2*1/2*1/2 upto infinity. On Sat, Aug 6, 2011 at 8:46 PM, Nitin Gupta gupta.nitingupta.ni...@gmail.com wrote: 1/6*5/6*5/6*3+ 1/6*1/6*5/6*3+ 1/6*1/6*1/6 =91/216 On Sat, Aug 6, 2011 at 8:24 PM, muthu raj muthura...@gmail.com wrote: Microsoft written: What is the probability of getting atleast one 6 in 3 attempts of a dice? *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sat, Aug 6, 2011 at 7:34 AM, shady sinv...@gmail.com wrote: Hi, A fair dice is rolled. Each time the value is noted and running sum is maintained. What is the expected number of runs needed so that the sum is even ? Can anyone tell how to solve this problem ? as well as other related problems of such sort -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] simple doubt
first one is right and second is wrong.because dp will store address of pointer and here you are storing address of int array. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Structure Q
head-x=100 is not right if you will first declare head=new list; head-x=100; will be right. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Duplicates in a string
int b[26]={0}; vectorcharc; for(i=0;a[i];i++) { if(!b[(a[i]-65)]) { b[(a[i]-65)]++; c.push_back(a[i]); } } for(i=0;ic.size();i++) coutc[i]; } -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Duplicates in a string
when you encounter the letter for first time then simply increment array having index=(ASCII value-65) and put that in vector next time when you will encounter the same variable again then condition will fail hence no change in content of vector hence in the end simply print the vector -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Makemytrip.com
coming for which branch?? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] help with stringstream (STL)
http://ideone.com/FtfQO On Thu, Aug 4, 2011 at 2:54 AM, Victor Manuel Grijalva Altamirano kavic1.mar...@gmail.com wrote: Hi, i don't know how to use stringstream of STL, if i have the string a=helloawordagoodabye, i need the next list: hello word good bye check that for each 'a' i need break the string...how -- Victor Manuel Grijalva Altamirano Universidad Tecnologica de La Mixteca -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
int a[N^2]={0},i,j; for(i=0;iN^2;i++) { cinj; a[j]++; } for(i=0;iN^2;i++) { if(a[i]!=0) { while(a[i]--) { couti\t; } } -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon
what was cutoff cgpa for amazon?? -- pankaj kumar -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] direct i
Even in array best case can be O(n). Why use stack? On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: Best case : O(n) Worst case : O(n^2) can be done using stack. Thinking of better solution. . On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.comwrote: O(n^2) algo is trivial. Can anybody think of a better approach ??? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] direct i
Can you please elaborate a little about your stack based solution. I was thinking of using queue but was unable to make a perfect algo. On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: i m suggesting stack not just for best case only . On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote: Even in array best case can be O(n). Why use stack? On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: Best case : O(n) Worst case : O(n^2) can be done using stack. Thinking of better solution. . On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.comwrote: O(n^2) algo is trivial. Can anybody think of a better approach ??? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] direct i
I think it's wrong approach. Can you explain with an example? On Wed, Jul 27, 2011 at 12:33 PM, pacific :-) pacific4...@gmail.com wrote: O(nlogn) 1. precompute the minimum of [ i+1 N] and store in b[i] 2. Now do a binary search for a[i] in b[i+1] in the range of b[i+1. N] On Wed, Jul 27, 2011 at 12:27 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: Let say stack S. 1.insert elements in S of A[] from right to left. 2.int val = S.top(); 3.S.pop(); 4.now check val with S.top() until u find any element smaller than val. 5.Note down the element pop it from stack 6.if step 4 is true , the push val in stack S and all elements which were popped in the order they were popped except the last matched candidate element. Yeah..dis algo is not very efficient.. On Wed, Jul 27, 2011 at 12:20 PM, Pankaj jatka.oppimi...@gmail.comwrote: Can you please elaborate a little about your stack based solution. I was thinking of using queue but was unable to make a perfect algo. On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: i m suggesting stack not just for best case only . On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.comwrote: Even in array best case can be O(n). Why use stack? On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza vishwakarma.ii...@gmail.com wrote: Best case : O(n) Worst case : O(n^2) can be done using stack. Thinking of better solution. . On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.com wrote: O(n^2) algo is trivial. Can anybody think of a better approach ??? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards, chinna. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C OUTPUT
Will not it depend on whether the machine is big or little endian? On Mon, Jul 25, 2011 at 11:50 AM, rajeev bharshetty rajeevr...@gmail.comwrote: 257 is stored as B A 0001 0001 So iptr if int* will be pointing to this above So if we typecast it as char* then it will point to 0001 (A) and *ptr+1 will point to 0001(B) Hope this clear . On Mon, Jul 25, 2011 at 11:41 AM, aditya kumar aditya.kumar130...@gmail.com wrote: main() { int i = 257; int *iPtr = i; printf(%d %d, *((char*)iPtr), *((char*)iPtr+1) ); } can any one explain me the o/p ?? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Amazon- Most Common Three sequence
You have a Log file that stores the users id, time(irrelevant), and webpage visited. Find the most common three-sequence webpage visited by the users. For example, you have a log file joe, 12:30pm,home joe, 12:31pm,about joe, 12:32pm,career james, 12:35pm, home james, 12:36pm, cart james, 12:37pm, maps mary, 12:41pm, home mary, 12:42pm, about mary, 12:43pm, career thus the most common sequence is home-about-career because the sequence occurs twice as oppose to home-car-maps which only occurs once. In addition, this file is a huge file with many more entries. http://www.careercup.com/question?id=9981709 -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: stacks
Can you please tell us from where we can find such questions? On Sat, Jul 23, 2011 at 4:21 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Nice question Kamakshi. The person above has given almost a perfect answer. For example i=3, we will pop the elements one by one from the top of the 1st stack and pushed to the 2nd stack until the value (top - i) is reached. On Sat, Jul 23, 2011 at 3:52 PM, ross jagadish1...@gmail.com wrote: Well. the idea of an array is - given an integer 'i', you should support RANDOM ACCESS to the ith element in the 1d array. Since, we have two stacks, if you want to access an ith element ( say, i = 5 ),pop all the top 4 elements from the 1st stack and push it to the second stack. Now, access the 5th element on top of the 1st stack, then, pop the elements from the 2nd stack back and push them to the 1st stack. However, access is O(n) due to the inherent property of a stack which forbids random access! On Jul 23, 2:00 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote: consider a language that does no have arrays...but u can define stack data type like stack s; using pop ,push and other operations on 2 stacks,how can one dimensions array can be implemented?? -- Regards, Kamakshi kamakshi...@gmail.com -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] output plzz
+1. The new group should only contain stuff related to C output and error detection and ques like that. Puzzles I think can be discussed here. wattsay? On Sat, Jul 23, 2011 at 10:44 PM, saurabh singh saurab...@gmail.com wrote: Anyways just share the link on the group.I am pretty sure the interested will join.No offences but sometimes it does get irritating when you open a post with subject Help! and when you expect some good algorithm problem you find questions like -x=++x---x+++x---x;whats the output. Whatever you decide please make it clear about what exactly the new group will be about(If at all you decide to make one.) PS:Thanks for the reply. On Sat, Jul 23, 2011 at 9:25 PM, shady sinv...@gmail.com wrote: I will get back to you tomorrow. Thanks a lot for the feedback :) Probably can have some contests organized as well, once a month on online judges..( no prizes though ) On Sat, Jul 23, 2011 at 9:21 PM, geek forgeek geekhori...@gmail.comwrote: even i second this gud idea On Sat , Jul 23, 2011 at 8:40 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @shady: yes its a good idea to have aptitude puzzles etc in other group On Sat, Jul 23, 2011 at 8:29 AM, shady sinv...@gmail.com wrote: nice idea Saurabh, but i don't think much people will join that group too, and the difference should be on the basis of type of questions asked. Any suggestions from others ? There we can ask questions related to debugging and puzzles, aptitude On Sat, Jul 23, 2011 at 8:51 PM, saurabh singh saurab...@gmail.comwrote: The break statement here breaks out of the do loop so the o/p hello hmmm give a break statement after hello and you will get only hello. PS:Seeing the number of C questions wont it be a better idea to start a parallel group especially for the same?My request to the group admins for the same. On Sat, Jul 23, 2011 at 8:47 PM, geek forgeek geekhori...@gmail.comwrote: #includestdio.h main() { int i=3; switch(i) { do { case 3: printf(\nhello); case 2:printf(\n h); break; case 1:printf(wat); break; case 0: printf(hai); }while(i--); } } -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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: Shooters in a circle
N people are standing in a circle ,they start shooting the person standing *next to their neighbour.*If they start firing in this way , determine who will be alive after this sequence?? Just for confirming, if only 2 person are left, then out of guilt of killing other's does the person who has gun shoot himself? On Fri, Jul 22, 2011 at 10:04 AM, surender sanke surend...@gmail.comwrote: josephus problem with mentioned k, k determines after how many persons to execute, u guys are considering k=1 as josephus problem. its with k=2 and still remains josephus problem. On Fri, Jul 22, 2011 at 12:40 AM, chetan kapoor chetankapoor...@gmail.com wrote: yeah u r wrong...the question says the person will kill the person standing next to its neighbor.. On Thu, Jul 21, 2011 at 4:16 PM, SAMMM somnath.nit...@gmail.com wrote: Consider this Example:- 1 2 3 4 5 6 7 1 In CIrcle 1 kills 2 3 kills 4 5 kills 6 7 kills 1 Remaining ppl :- 3 5 7 3 kills 5 7 kills 3 Remain- 7 This is the sequence .. i guess Isit -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Largest substring with unique characters
Vaibhav What do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Fwd: [algogeeks] Re: Largest substring with unique characters
Vaibhav What do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters a-z. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav What do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps
In my latest interview I encountered the following puzzle. There are 100 prisoners in the prison. All of them have either black or white cap. Jailer has asked them to stand in the queue such that nth guy can see caps of all the guys standing ahead of him, but he can not see his own cap. It means Guy standing at 100th position can see caps of all other 99 guys. Prisoner standing at 99th position can see caps of rest of 98 guys standing ahead of him. Now jailer proposes to release the guy who can guess correct color of his own cap. Assuming All the prisoner are nice guys ;), who can sacrifice for others, device a method which can help to release maximum number of prisoners. On Fri, Jul 22, 2011 at 7:46 PM, Vishal Jain jainv...@gmail.com wrote: Hi All, In my last interview(given few months back), I was asked the following puzzle.. http://goo.gl/jrnpc Could you please tell me the solution for the same? Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved is bigger. P *We have a responsibility to the environment.* *Before printing this e-mail or any other document, let's ask ourselves whether we need a hard copy.* -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps
Skipp Riddle, Yes. 100th prisoner will risk his life. Similar puzzle was discuss recently. Does anyone remember the name or thread? ~ Pankaj On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: Worst case 99 get released. Is that correct..? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Fwd: [algogeeks] Re: Largest substring with unique characters
*abcdea*ifjlbmnodpq For this once you encounter a at 6th position, You can update your max. Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters a-z. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters
Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters a-z. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message
Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps
Chetan, No. How could you relate this problem with that? Do you find something similar? ~ Pankaj On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor chetankapoor...@gmail.comwrote: josehus problem??? On Fri, Jul 22, 2011 at 7:57 PM, Pankaj jatka.oppimi...@gmail.com wrote: Skipp Riddle, Yes. 100th prisoner will risk his life. Similar puzzle was discuss recently. Does anyone remember the name or thread? ~ Pankaj On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: Worst case 99 get released. Is that correct..? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: Fwd: [algogeeks] Re: Largest substring with unique characters
aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position, You can update your max.Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum unique string in above test case? Try printing each sub string formed whenever you hit a duplicate. It's still O(N) though if we have constant number of characters :) On Fri, Jul 22, 2011 at 7:50 PM, vaibhavmitta...@gmail.com wrote: Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have it largest possible unique string). Otherwise keep checking. So overall maximum complexity can be (MAX*n) where max will be unique letters. Abhishek, I think the final complexity can never be O(n^2) if you only consider unique letters az. The suggested soln is purely bruteforce. If anyone can think of a better solution then please reply. Cheers Pankaj On Fri, Jul 22, 2011 at 7:37 PM, Pankaj jatka.oppimi...@gmail.com wrote: VaibhavWhat do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6, max = max(5, 6-4)= max(5, 2) = 5 hence ur ans = 5 Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Interstellar Overdrive abhi123khat...@gmail.com wrote: @svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hG6ZNcG5fMMJ. 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. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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]
Just like you do for int * int *p=(int *) malloc(sizeof(int)); double *ptr_lf = (double *) malloc(sizeof(double)); On Sat, Jul 23, 2011 at 12:32 AM, hurtlocker bhavesh24...@rediffmail.comwrote: how to allocate memory for a double pointer ..?? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
double **p= (double **) malloc(sizeof(double *)); On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal agr.bhav...@gmail.comwrote: double pointer mean like **p hoe to allocate memory for this -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
https://ideone.com/tr3Q7 On Sat, Jul 23, 2011 at 12:42 AM, Pankaj jatka.oppimi...@gmail.com wrote: double **p= (double **) malloc(sizeof(double *)); On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal agr.bhav...@gmail.comwrote: double pointer mean like **p hoe to allocate memory for this -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Circular list
If you know circular list, what is avoiding you from maintaining a tail pointer. You just need to tweak insert and delete function a little bit for corner cases. On Sat, Jul 23, 2011 at 12:50 AM, rShetty rajeevr...@gmail.com wrote: Algorithm Please ... Thank You On Jul 23, 12:17 am, vaibhav shukla vaibhav200...@gmail.com wrote: maintain just a tail pointer On Sat, Jul 23, 2011 at 12:45 AM, rShetty rajeevr...@gmail.com wrote: Come Up with an Algorithm to implement the insertion of a node in circular linked list without actually traversing the list ? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav MCA -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
int **x; x = new int*[n]; for (int i = 0; i n; i++){ x[i] = new int[m]; This algorithm will create a m*n matrix. x= new int*[n] is same as allocating array of n which will be of (Int *) type. It will store the address of n arrays of m size. x[i]= new int[m] here we are allocating an array of m int. And assigning the address of each array to memory allocated above. Please let me know if I am wrong. On Sat, Jul 23, 2011 at 12:59 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: @rakib:can u please explain ur answer On Sat, Jul 23, 2011 at 12:48 AM, Pankaj jatka.oppimi...@gmail.comwrote: https://ideone.com/tr3Q7 On Sat, Jul 23, 2011 at 12:42 AM, Pankaj jatka.oppimi...@gmail.comwrote: double **p= (double **) malloc(sizeof(double *)); On Sat, Jul 23, 2011 at 12:40 AM, Bhavesh agrawal agr.bhav...@gmail.com wrote: double pointer mean like **p hoe to allocate memory for this -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Circular list
That can never be done in constant time :). If you can find one solution, then please let us know. On Sat, Jul 23, 2011 at 1:13 AM, rShetty rajeevr...@gmail.com wrote: SO what about If my Linked list is a sorted list and the new node I wanna insert must maintain that sorted nature , So can then be the insertion of a node be done in constant time without traversing the list ?? On Jul 23, 12:26 am, Pankaj jatka.oppimi...@gmail.com wrote: If you know circular list, what is avoiding you from maintaining a tail pointer. You just need to tweak insert and delete function a little bit for corner cases. On Sat, Jul 23, 2011 at 12:50 AM, rShetty rajeevr...@gmail.com wrote: Algorithm Please ... Thank You On Jul 23, 12:17 am, vaibhav shukla vaibhav200...@gmail.com wrote: maintain just a tail pointer On Sat, Jul 23, 2011 at 12:45 AM, rShetty rajeevr...@gmail.com wrote: Come Up with an Algorithm to implement the insertion of a node in circular linked list without actually traversing the list ? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav MCA -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sorting in O(n)
For linklist? How On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: use counting sort.. On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote: How to sort Linked lists in O(n) time ?? Give the algorithm or the explanation or clue to tackle the problem -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Shooters in a circle
int n,temp,pow2=1; cinn; temp=n; while(temp){ if(temp%2==) n-=pow2; pow2*=2; temp=temp/2; } On Thu, Jul 21, 2011 at 2:08 PM, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: I forgot to mention that you have to program the problem in any language of your choice.But C will be preferred. On Thu, Jul 21, 2011 at 1:49 PM, karthiga m karthichandr...@gmail.comwrote: i got this solution .. assuming when n=1 1st person will be alive when n=21st person will be alive , when n=3 3rd person will be alive when n=4 1st person will be alive when n=5 3rd one will be alive when n=6 5th person will be alive when n=7 7th one wil be alive when n=8 1st person will be alive ..when n=16 1st person will be live when n=32 1st person will be alive..by this we can conclude that for n=1,2,4,8,16,32,64 the 1st person will not die... between this the odd one's will not die.. the sequence will be like between n=2 and n=4 ..3rd one will not die, same as between n=4 and n=8 3rd,5th,7th one will not die... so by filling odd no's between the values for what we getting one we can find the person who will be alive. hence for 2 POWER n the 1st person will be alive if anything wrong in this pls correct me..!!! On 7/21/11, SAMM somnath.nit...@gmail.com wrote: I think it is related to Joshepus problm... ckeck wikipedia for more info. On 7/20/11, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: If n people are standing in a circle ,they start shooting the person standing next to their neighbour.If they start firing in this way , determine who will be alive after this 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Somnath Singh -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Shooters in a circle
Ingore the above code. It is wrong. On Thu, Jul 21, 2011 at 2:39 PM, Pankaj jatka.oppimi...@gmail.com wrote: int n,temp,pow2=1; cinn; temp=n; while(temp){ if(temp%2==) n-=pow2; pow2*=2; temp=temp/2; } On Thu, Jul 21, 2011 at 2:08 PM, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: I forgot to mention that you have to program the problem in any language of your choice.But C will be preferred. On Thu, Jul 21, 2011 at 1:49 PM, karthiga m karthichandr...@gmail.comwrote: i got this solution .. assuming when n=1 1st person will be alive when n=21st person will be alive , when n=3 3rd person will be alive when n=4 1st person will be alive when n=5 3rd one will be alive when n=6 5th person will be alive when n=7 7th one wil be alive when n=8 1st person will be alive ..when n=16 1st person will be live when n=32 1st person will be alive..by this we can conclude that for n=1,2,4,8,16,32,64 the 1st person will not die... between this the odd one's will not die.. the sequence will be like between n=2 and n=4 ..3rd one will not die, same as between n=4 and n=8 3rd,5th,7th one will not die... so by filling odd no's between the values for what we getting one we can find the person who will be alive. hence for 2 POWER n the 1st person will be alive if anything wrong in this pls correct me..!!! On 7/21/11, SAMM somnath.nit...@gmail.com wrote: I think it is related to Joshepus problm... ckeck wikipedia for more info. On 7/20/11, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: If n people are standing in a circle ,they start shooting the person standing next to their neighbour.If they start firing in this way , determine who will be alive after this 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Somnath Singh -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Circle Circle more Circles .........
http://www.codechef.com/FEB10/problems/M5/ On Wed, Jul 20, 2011 at 5:35 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: @Dumanshu..i am not partitioning them into just two queues... Moreover I just gave a raw idea...and yeah the complexity is in the order of n^2 only. There are many chances of improvement in it.. On Wed, Jul 20, 2011 at 5:30 PM, Dumanshu duman...@gmail.com wrote: @Piyush: Initially for partitioning the given circles into the 2 queues u r having an O(n^2) loop, so u are comparing each circle with every other. Now, it is possible that u have 3 or more circles A,B,C intersecting if i got ur algo correct, ur intersection queue will have AB, BC, CA. So, according to the geometry, u will find the areas. But this area would be different than the actual area for intersection of A,B,C. On Jul 20, 3:48 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote: I would like to redefine my algo with cases clarified... Create a queue that is made to contain the points... say points queue [1000]; for i:1 to n for j:i+1 to n Calculate d (distance between the two centers) if (d = r0 + r1) keep them in two separate queues //the circles don't intersect if(d==0 || d= abs(r0-r1)) ignore the circle with smaller radius // one circle wholly contains another such that the borders do not overlap, or overlap exactly (e.g. two identical circles) else keep both of them in one single queue Now calculate the area of the circles in those queues which have single element... those with more than one element..calculate the area using simple geometry...You can take help of this.. http://mathworld.wolfram.com/Circle-CircleIntersection.html Hope its clear now... On 7/20/11, SAMMM somnath.nit...@gmail.com wrote: I doubth . For (d r0 + r1) ignore the point with smaller radius as it will overshadowed the bigger circle completely There may be a case where the circle is partially overlapped by the other circles. Then this algo will fail . The area will be of like these :- Suppose 3 circles are there X,YZ . Then the area will be :- Case1:- X+Y+Z Case2:- X+(YUZ) == Y + Z - (YnZ) --- intersection case3:- There circle can overlap ... like these . Then Will your algo work .. I guess no . -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * NEVER SAY NEVER * -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Contiguous subarray with sum zero
Given an array with + and - numbers, including zero, Write an algorithm to find all the possible sub arrays which sum up to zero. For example, if given array is 20 , -9 , 3 , 1, 5 , 0, -6 , 9 Then possible sub arrays are: -9, 3, 1, 5 0 1, 5, 0, -6 -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Output
I think sunny meant that in IA-64 the pointer is of size 8 but here we are assigning it to int *p. So, the segfault can occur. On Wed, Jul 20, 2011 at 6:52 PM, Sandeep Jain sandeep6...@gmail.com wrote: @Sunny: I couldn't understand how size of int int* matter here?? Regards, Sandeep Jain On Mon, Jul 18, 2011 at 11:20 PM, sunny agrawal sunny816.i...@gmail.comwrote: size of pointers is equal to word size of the machine so on 64 bit machine size of pointer will be 8 byte while that of int is 4 byte On Mon, Jul 18, 2011 at 11:17 PM, Swathi chukka.swa...@gmail.com wrote: Try check if (p == NULL)... may be memory is not allocated... On Mon, Jul 18, 2011 at 10:52 PM, Balaji S balaji.ceg...@gmail.comwrote: The following C program segfaults of IA-64, but works fine on IA-32. * int main() { int* p; p = (int*)malloc(sizeof(int)); *p = 10; return 0; } * Why does it happen so? -- With Regards, Balaji.S -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Ever growing sorted linked list
One a not so standard way of doing that is while creating the link list, keep an extra pointer in the node to point to the jump location. Just hold the previous node in a temp say address of 2 node and when i/p reaches 4, point the jumper pointer to 4 and make 4 the next jumper pointer. On Wed, Jul 20, 2011 at 7:27 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: @Popli : Bingo , that is what i was thinking and mentioned in my previous post.. On Wed, Jul 20, 2011 at 7:08 PM, Gaurav Popli abeygau...@gmail.comwrote: i want to ask one thing...the way some are saying first check with 2 then 4 and then 16to reach at that place we are suppose to traverse it and also hav eto put a condition say like countn or something...in this case also we are comparing so whats the usecorrect me if im wrong. On Wed, Jul 20, 2011 at 6:58 PM, bittu shashank7andr...@gmail.com wrote: can be done in O(n) find tow nodes from starting position find two nodes p,q such that p k k q as linked list is sorted we have to keep going on in right direction complexity will no less then O(N) as its linked list there is no notion of binary search sorted linked list think out why ? only think we can apply some logic to reduce the comparisons that's i also think will be gr8 improvement but approach sounds good if start comparing the nodes value using multiple of 2 fact .e.g. take an integer i=2^j from j=0 to start comparing 2^0th node, 2^1th node, 2^2th node2^jth node might be we are able to reduce the number of comparisons do notify me via gmail if i am wrong if u find difficulty in TC ? else happy learning if this would have been sorted array then we could have been solved it O(logn) suing same approach. Thanks Shashank Mani Computer Science Birla Institute of Technology, Mesra -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Contiguous subarray with sum zero
*Contiguous elements* On Thu, Jul 21, 2011 at 12:12 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: for the above example,there are more possible sub arrays like -9,9 -9,0,9 On Thu, Jul 21, 2011 at 12:06 AM, sagar pareek sagarpar...@gmail.comwrote: @ankur pls explain through an example by taking above problem. On Wed, Jul 20, 2011 at 10:52 PM, SAMMM somnath.nit...@gmail.com wrote: Nice solution dude . Like that one -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Facebook Interview Question....Heavy Number
best approach for such problems is try to solve for very small numbers then do DP for solve large numbers. as follows single digit = 7,8,9 answer = 3 [i am taking 7 inclussive] double digit= 7*2 = 14. now smallest number can be. 59=1 68, 69 = 2 77 78, 79,=3 86, 87, 88, 89=4 95,96,97,98,99 =5 3 digits. 7*3=21 smallest number= 399=1 489,498,499=3 579, 588,589,597,598,599=6 can you see the pattern? 1 digit = 1,1,1 2n'd digit = 1,2,3,4,5 3rd digit = 1,3,6, 10 now we can easily do DP and get the answer !! :) Happy coding :) On Apr 4, 8:52 pm, bittu shashank7andr...@gmail.com wrote: Hi Geeks, One of The My Friend had This Question in His Technical Round of Facebook, I m going to share with you.lest see how geek approach this...Plz don't make this post spam..by discussing whats ur friend name, wich colge, etc etc..just share your approach, think solve the question, even Google search wont give you correct efficient approach ,answer for this question..so think your self.. O(n^2) Solution is Obvious ..but .it wont work for 10 million as a limit so not a good solution we have to solve it using best approach algo..as we have so here is the question...From Facebook... /* A non-negative integer is called heavy if the average value of its digits in decimal representation exceeds 7. Assume that 0 has average value of its digits equal to 0. For example the number 8698 is heavy, because the average value of its digits equal to (8+6+9+8)/4 = 7.75. The number 53141 has the average value of its digits equal to (5+3+1+4+1)/5 = 2.6, so it is not heavy. Write a function int heavy_decimal_count(int a,int b); that given two non-negative integers A and B returns the number of heavy integers in the interval [A..B] (both ends included). Assume that 0 =A = B = 200,000,000 Range Given ..It Really Matters Your Program should not give time out memory error For example, given A=8,675 and B=8,689 the function should return 5, because there are 5 heavy integers in range [8,675..8,689]: 8675 avg=6.5 8676 avg=6.75 8677 avg=7 8678 avg=7.25 HEAVY 8679 avg=7.5 HEAVY 8680 avg=5.5 8681 avg=5.75 8682 avg=6 8683 avg=6.25 8684 avg=6.5 8685 avg=6.75 8686 avg=7 8687 avg=7.25 HEAVY 8688 avg=7.5 HEAVY 8689 avg=7.75 HEAVY you have to keep in mind for given range e.g given B=2 Billion Its Man Thing so what happen when A=1 Billion B=2 Billion */ Go Ahead Thanks Regards Shashank Mani Cell 9740852296 -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
in fn1 ptr is pointer to integer i and you are changing content of i by using *ptr from 10 to 100 in fn ptr is pointer to integer i and you are changing pointer ptr by pointing to val(now ptr no more point to integer i).so here only pointer is changing not value. am i clear to you? On Fri, Apr 1, 2011 at 9:05 AM, navin navin.myhr...@gmail.com wrote: see this c code. #includestdio.h void fn (int *ptr) { const int val=100; ptr=val; } void fn1(int *ptr) { *ptr = 100; } main() { int i=10; printf(%d , i); fn(i); printf(%d , i); fn1(i); printf(%d , i); } What is the difference between fn and fn1? I expected the output to be 10 100 100 but it came as 10 10 100. can anyone explain what happens in fn. why 100 in fn is not stored in ptr. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Pankaj Agarwal B.Tech(Final Year Undergraduate) Communication and Computer Engineering LNMIIT,jaipur -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] [brain teaser ] 7march
i hope statement is- i am telling lie if i don't get a gold coin. clear me if i am wrong On Mon, Mar 7, 2011 at 5:59 PM, amit singh amit.lu...@gmail.com wrote: i will get a gold coin or i will not get a coin On Mon, Mar 7, 2011 at 1:41 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Get Gold Coin Problem Solution* * *Imagine there are 3 coins on the table: gold, silver, and copper. If you make a truthful statement, you will get one coin. If you make a false statement, you will get nothing. What sentence can guarantee you getting the gold coin? *Update Your Answers at *: Click Herehttp://dailybrainteaser.blogspot.com/2011/03/7march.html Solution: Will be updated after 1 day -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Invitation for Online programming competition DOPE
Hello, we like to invite you all to participate in Online Programming Contest organized as a part of Daksh 2011, an international level Technical festival of SASTRA University, Thanjavur, Tamilnadu We have two competitions: 1) DOPE Dope is a 6 hour ACM ICPC style algorithmic competition with team of size atmost 2. The contest will be held on 20th Feb, 2011 from 9.00 hrs IST (GMT +5:30); check your time zone http://www.timeanddate.com/worldclock/fixedtime.html?year=2011month=02day=20hour=3min=30sec=0p1=0 You can register your self to http://daksh.sastra.edu/online/online.php Practice on http://www.spoj.pl/DOPE/ 2) Code-Athlon It is c/c++ programming event which has first online round and then 2 onsite round first round problems will appear on event link on 15th Feb 2011 at 0.00 hrs IST (GMT +5:30) and last date of submission of answers will be till 18th Feb 2011, 23.59 hrs IST (GMT +5:30). you can register your team to http://daksh.sastra.edu/events.php#events/comp Thanks and Regards Team, Daksh 2011 -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Simple Question about simple algorithm
Hi , here goes the code.. let's say you have an array of n numbers.Here n could be 1,2,3.. it goes as follows: function bubblesort (A : list[1..n]) { var int i, j; for i from n downto 1 { for j from 1 to i-1 { if (A[j] A[j+1]) swap(A[j], A[j+1]) } } } this is the simplest algo.hope you can implement this in java... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---