Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //let input = [1, 2, 3, 4, 4, 3, 2, 1];//Yes
- //let input = [3,4,5,3,4,5];//No
- let input =[7,8,9,8,7] //Yes
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let symmetric = true;
- let n =+gets();
- // loop iterate up to the middle and compare first element with last element
- for(let i=0; i<n/2;i++){
- if(input[i] != input[n-i-1]){
- symmetric = false;
- }
- }
- if (symmetric){
- print('Yes');
- }
- else {
- print('No');
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement