Jordan Smith
BAN USERReally good solution but would it not be better to first check if the string you are comparing to your (smallest or biggest) sting is smaller or bigger before going into the recursive function?
Bad phrasing ok so what I mean is... both your smallest/largest left/right you should first see if the string is larger or smaller than your current largest or smallest string. This could save time and resources by not entering the recursive isRight/isLeft function. If the string isn't larger or smaller, throw it out and move to the next.
I was also thinking that instead of writing two functions for each hand, you could add a parameter detailing which hand you would like to compare then you only have to write one function for each. You could specify which hand in the LargestOneHandWord() function. This could save you actual physical time and make the solution a bit shorter.
This question would be best answered with more questions to narrow down the problem. Asking things like:
- Jordan Smith August 09, 2013Where is the data coming from?
How will the data be used?
etc.
This will give you a better understanding of if the data is partially sorted or not and later of implementation, if the data needed to be randomly accessed. You can then sniff out if the worse case is for the sort you will be using will ever be reached and if you could optimize better with a sort because the data is identical to that of a best case.