Hey ankit, i gave java code also...didn't u check it in the link...anyway i am explaining here.........
*Note : Position count starts from 0. * *ex: {1,2,3,4} ...position of '1' is zero............* * * *In the below approach,we are checking element position in the modified list(after deletion operation in the previous iteration).* given array is : ar[]= {1,3,2,4,5,4,2}. construct a list with array elements and sort it.Now list contains :1,2,2,3,4,4,5 Now traverse through array elements from i=0 to n-1(start to end) store result in result[] array. list is *1*-2-2-3-4-4-5 for i=0, a[0]=1,search for a[0] position in the list(right occurrence).a[0]=1 position in list is '0' add '0' to result.===>result[0]=0; remove the element a[0] from the list.now list contains 2-2-*3*-4-4-5 for i=1,a[1]=3,search for a[1] position in the list(right occurence).a[1]=3 position in list is '2' add '2' to result====>result[1]=2 remove the element a[1] from the list.now list contains 2-*2*-4-4-5 for i=2,a[2]=2,search for a[2] position in the list(right occurence).a[2]=2 position in list is '1' add '1' to result====>result[2]=1 remove the element a[2] from the list.now list contains 2-4-*4*-5 for i=3,a[3]=4,search for a[3] position in the list(right occurence).a[3]=4 position in list is '2' add '2' to result====>result[3]=2 remove the element a[3] from the list.now list contains 2-4-5 for i=4,a[4]=5,search for a[4] position in the list(right occurence).a[4]=5 position in list is '2' add '2' to result====>result[4]=2 remove the element a[4] from the list.now list contains 2-*4* for i=5,a[5]=4,search for a[5] position in the list(right occurence).a[5]=4 position in list is '1' add '1' to result====>result[5]=1 remove the element a[5] from the list.now list contains 2 for i=6,a[6]=2,search for a[6] position in the list(right occurence).a[6]=2 position in list is '0' add '0' to result====>result[6]=0 remove the element a[6] from the list.now list is empty. resultant array contains : from all conditions : add '0' to result.===>result[0]=0; add '2' to result====>result[1]=2 add '1' to result====>result[2]=1 add '1' to result====>result[3]=2 add '2' to result====>result[4]=2 add '1' to result====>result[5]=1 add '0' to result====>result[6]=0 expected result {0,2,1,2,2,1,0} actual result ==>{0,2,1,2,2,1,0} I hope u r clear now.............Please let me know if you still have doubts........... U can execute the java code given in link : http://rajeevprasanna.blogspot.com/2011/07/count-number-of-min-elements-on-right.html I will be more happy if you give me failed cases................... On Wed, Jul 27, 2011 at 11:25 AM, ankit sambyal <ankitsamb...@gmail.com>wrote: > @rajeev :try the example given in the question. And explain ur algo with > that example > -- Thank You Rajeev 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.