← Unit 4 · all exercises
Saved in this browser only

The same both ways

Return true when the array reads the same forwards and backwards. Empty and single-item arrays both count as true.

boolean isPalindrome(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.isPalindrome(new int[]{1, 2, 1}) → true
  • Solution.isPalindrome(new int[]{1, 2, 3}) → false

There are also 4 hidden tests you can't see. Solve the problem, not the examples.