Have a look at this earlier discussion where the problem was to find for array[i], the next nearest larger element than array[i] in the remaining array. https://groups.google.com/d/topic/algogeeks/A51KGsPMtAE/discussion
Look at the solution suggested by balaji. Modifying it shall solve your problem. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
