Ad
  • Custom User Avatar

    There’s absolutely no redundancy here—arrays are mutable by nature, and returning the array from arguments (in cases where N >= arr.length) can lead to unexpected behavior down the line. This practice is known as "defensive copying." If you make it a habit to run a red light just because there are no cars in sight, one day you’ll run it when there is a car. The same logic applies to code. Personally, I see no difference between writing production-level code and solving problems on Codewars—the rules are there for a reason, and they apply everywhere.

  • Custom User Avatar

    Since arrays are not immutable it would be bad if a function has different behaviour depending on the inputs.