Ad
  • Custom User Avatar

    You performed checking on whether the left-end equals to right-end when the iteration is still going (i.e, the loop has not reached its endpoint), resulting in inaccurate comparison. Also, your code will always output nil because you had an early exit before returning the result, plus nothing to be returned when there is no match between left-end and right-end

  • Default User Avatar

    I don't think you need .each at all here, and I think you'll find the array arr will accept .count but not .length (length works for strings but not arrays) – does this help?