Ad
  • Custom User Avatar

    a Set<String> would make much more sense as a return type here (at least in static type languages).

  • Custom User Avatar

    You need not initialize arrLn[i] = 0 in java, since int being a primitive type is Initialized to 0 anyhow.
    Apart from that, it's the perfect solution. No side effect to the original input array, neither you have created a copy of the array.