I was trying to approach this problem by splitting half. For example,
set the mid “4” and then split left and right. Define these like left = [1,2], right=[2,1] and mid=4. So all i have to do is right.reverse() to compare with left part. if(left === right.reverse()) should return “YES” else it’s not!
If the each row’s length is even number,
For example, if the length is 6, the left and right length should be 3.