LogiQuest

367. Palindrome Linked List

EasyTwo Pointers

Print YES if the list reads the same forwards and backwards, else NO. Try to use O(1) extra space.

Input format

Line 1: n Line 2: n values

Output format

YES or NO

Example 1

Input

4
1 2 2 1

Output

YES

Example 2

Input

2
1 2

Output

NO

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…