geworm - I'm not sure what it's time complexity would be. I didn't code this up. Just worked it out with paper and pen. I did a somewhat similar program last year, so it wasn't that much of a stretch.
geworm's algo appears more elegant for this solution, with the addition of the "prefix array computation". What algo and code have you tried to solve this problem, M. M. ? Toss it up and let's see where you are with solving this. Having other members of the forum write up code for you might be fun for them, but hardly educational for you. If you want to be a good programmer, there's one thing you MUST do - programming! You have to exercise those wings before you can use them to fly to considerable heights. Ask any bird. :-) Just now I have a better algo in mind to solve this problem. I may code it up if March Madness isn't too exciting. Adak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---