Ad
  • Custom User Avatar

    I like that your solution took only 2 lines of code, looks elegant.

    I agree with Einstine1984, about the redundancy of storing numbers for each digit of the input.

    Also, isn't it redundant to perform substring for each digit of a number?
    Maybe it would be more efficient to perform substring only if current digit is greater than the first digit of the current max value?

  • Custom User Avatar

    String#matches compiles Pattern for each string. It would be more efficient to extract Pattern as a static final field and then validates strings via Matcher manually.