• Custom User Avatar

    Apache Commons is not a standard part of the Java language

    Well it is part of the library supplied by Codewars's test runner.

    There's nothing bad about using external packages.

  • Custom User Avatar

    It doesn't, because the input string is thread safe and we don't use member variables.

  • Custom User Avatar

    Can you explain How can we know does the code need thread safety or not?

  • Custom User Avatar

    IMO, IMO is superior to IMHO

  • Custom User Avatar

    I agree with you, there is, IMHO, no need at all for thread safety here

  • Custom User Avatar

    Agreed, for local variables it doesn't make sense

  • Custom User Avatar

    That's true. And you could also improve your solution.
    It's low-cohesive and doesn't meet with the DRY principle. Same work needed to remove glaring redundancy in order to beautify this code.

  • Custom User Avatar

    Done

  • Custom User Avatar

    Big O notation is used to discuss how things grow as the dataset gets larger. It is not strictly limited to runtime, and is never in fact measuring runtime. It is simply a way of mathematically approximating how things grow.

    It can be used to talk about the number of operations performed, number of comparisons used, memory required, memory allocations, etc. Its all in how you slice the code and determine what the most costly factors are. Whatever is most costly will generally have the biggest impact on runtime/performance.

    In this case, memory allocations are the most costly part of the algorithm. And making 1 allocation, versus 3N + 1 allocations is the part that effects both the runtime and memory usage the most.

  • Custom User Avatar

    Its been months since you reply but if you are still wondering when we measure how much time it takes for an algorithm to finish, we do not measure in time but in O(n), you can search the Big O notation(if u havent already) and youll see. btw if im wrong someone correct me im a newbie aswell.

  • Custom User Avatar

    It can be simplifed even more using constant space

  • Custom User Avatar

    @FArekkusu where can we find out why it was retired?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    i see everyone talking about 'O(N)' and that kind of stuff what does it all mean. i am a newbie by the way.
    lol obviously.

  • Custom User Avatar

    Thank You! Glad to see in codewars someone concerns about efficiency.
    It is even possible to determine the day of the week for 1 January without new Date().

    P.S. Sometimes I do much stranger things...

  • Loading more items...