12. Quiz N

(similarEnds) An array has similar N-ends if the front and back N numbers are in the reversed order.

Return the largest N value for which an array has the same N-ends.

  • N is a positive integer.
  • Give 0 if the ends are not similar at all.

Examples:

  1. similarEnds([20,30,40]) => 0.
  2. similarEnds([20,30,4,5,30,20]) => 2.
  3. similarEnds([20,30,40,50,50,40,30,20]) => 8. The repeating segments overlap.
  4. similarEnds([10,20,30,20,10]) => 5.
Last modified August 18, 2023: 2022-2023 End State (7352e87)