Ad
  • Custom User Avatar

    absoluetly I agree with you I think this is odd

  • Default User Avatar

    I guess it depends on which paradigm you're more familiar with. The top-voted solution uses an imperative approach, while mine uses a functional approach which may come off a bit unnatural because Java's functional features are relatively new. I should have split the calls of map and collect into new lines (like I did in my fork), but apart from that I still like my solution very much.
    The biggest problem with your solution are the inline comments. These are generally an indication for code that's not self-explanatory.

  • Custom User Avatar

    Are you familar with Java streams? They're pretty great and is pretty easy to read (given that you know about them of course, they're only there since Java 8).

    At least it's infinitely better than tons of for loops and if statements (like your solution does) ;-)