posted 12 years ago
Bhargav,
A couple of suggestions..
First, I would use more descriptive variable names. "k" doesn't tell me anything. however, "maxFound" tells me EXACTLY what it means...
If you want to see why your code doesn't work, put a bunch of System.out.println() statements in it to see what it is REALLY doing. something like this:
>
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors