Ad
  • Custom User Avatar

    I updated this solution to be more efficient and only iterate over the array a single time. I don't know how to get everything onto a single line though. I think this is pretty good though.

  • Custom User Avatar

    WIoHu, if you're going to critique something because it's 'not good for beginners', your explanation should meet a basic level of quality, your tone should have a modicum of respectfulness to it, and I SHOULD BE ABLE TO UNDERSTAND THE ISSUE AS A BEGINNER.
    I know I'm years and years after the fact, but this crap just made me feel bad about what I learned (on my own, not from this person's solution).
    If you really cared about beginners, you would 1) use language that was easy for beginners to understand, and focus more on explaining exactly where and why the other person's code is 'bad', 2) approach it with a clear intent to educate and not denegrate, and 3) when you had to clarify something, take the time to disambiguate the good solution vs the bad solution.
    Otherwise you're not doing it to help beginners. You're doing it to feel a sense of superiority over others because you've learned something they haven't yet.
    It's bloodsport.