Timeline for Reversing a string
Current License: CC BY-SA 2.5
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 9, 2013 at 20:31 | comment | added | Dennis Rongo |
@BillyONeal, @JaimePardos is probably correct that the interviewer just wanted to see your thought process on tackling this problem. IMHO, I like the for for the simple reason that it's easier to read and you don't have to worry about setting the start and end index for each loop.
|
|
Apr 10, 2011 at 20:45 | comment | added | raven | @Billy Oneal: Sorry, you're right, I was thinking in C++ where we still don't have a for each, so I didn't use the best example. However, it still applies if you don't want to process every item in the list, or need to do so in specific order (i.e. traverse a list backwards) | |
Apr 3, 2011 at 19:00 | comment | added | Billy ONeal |
But if you limit the for loop to that only, then there's little reason for it to exist at all -- foreach handles that. (i.e. foreach(var idx = Enumerable.Range(0, maxI)) { ... } ) (That syntax isn't 100% correct but it gets the idea)
|
|
Apr 3, 2011 at 0:46 | history | answered | raven | CC BY-SA 2.5 |