[Algorithm] 22 week(6.13 ~ 6.19) 1/3

Dev_min·2022년 6월 13일
0

algorithm

목록 보기
71/157

234. Palindrome Linked List

var isPalindrome = function(head) {
    function isValidList(recursiveHead) {
        if (recursiveHead == null) {
            return true;
        }

        const next = isValidList(recursiveHead.next);

        const valid = recursiveHead.val === head.val;

        head = head.next;
        return next && valid;
    }
    return isValidList(head);
};
profile
TIL record

0개의 댓글