KimMinJun
Coding Note
KimMinJun
전체 방문자
오늘
어제
  • 분류 전체보기 (486)
    • ALGORITHM (11)
      • 정렬 (6)
      • 최단경로 (1)
      • 자료구조 (1)
      • 슬라이딩 윈도우 (1)
      • etc (2)
    • Git (5)
    • Web (24)
      • Vanilla JS (13)
      • TS (2)
      • React (7)
      • ETC (1)
    • React 공식문서 (번역, 공부) (11)
      • Quick Start (2)
      • Installation (0)
      • Describing the UI (9)
      • Adding Interactivity (0)
      • Managing State (0)
      • Escape Hatches (0)
    • Next.js 공식문서 (번역, 공부) (3)
      • Getting Started (2)
      • Building Your Application (1)
    • PS (431)
      • 백준 (187)
      • Programmers (104)
      • CodeUp (21)
      • STL (3)
      • 제코베 JS 100제 (50)
      • SWEA (0)
      • LeetCode (65)
    • IT (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 관리

공지사항

인기 글

태그

  • 다이나믹 프로그래밍
  • Level 2
  • Level 0
  • 정렬
  • js
  • LeetCode
  • Level1
  • Level 1
  • string
  • C++
  • tree
  • 문자열
  • C
  • 그래프
  • recursion
  • 백준
  • programmers
  • 제코베 JS 100제
  • codeup
  • 수학

최근 댓글

최근 글

hELLO · Designed By 정상우.
KimMinJun

Coding Note

PS/LeetCode

LeetCode / Linked List / 234번 / Palindrome Linked List / JS

2023. 4. 19. 23:47

< 문제 바로가기 >

 

Palindrome Linked List - LeetCode

Can you solve this real interview question? Palindrome Linked List - Given the head of a singly linked list, return true if it is a palindrome or false otherwise.   Example 1: [https://assets.leetcode.com/uploads/2021/03/03/pal1linked-list.jpg] Input: hea

leetcode.com

 

< 문제 간단설명 >

주어진 Linked List가 팰린드롬인지, 즉 앞으로해도 뒤로해도 같은지 판단하는 문제이다.

 

/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {boolean}
 */
 var isPalindrome = function(head) {
  let tmp = [];
  while(head) {
      tmp.push(head.val);
      head = head.next;
  }

  return tmp.join('') === tmp.reverse().join('')
};

 

저작자표시 (새창열림)

'PS > LeetCode' 카테고리의 다른 글

LeetCode / Linked List / 328번 / Odd Even Linked List / JS  (0) 2023.04.28
LeetCode / Simulation / 1706번 / Where Will the Ball Fall / JS  (0) 2023.04.20
LeetCode / Linked List / 19번 / Remove Nth Node From End of List / JS  (0) 2023.04.19
LeetCode / String / 43번 / Multiply Strings / JS  (0) 2023.04.19
    'PS/LeetCode' 카테고리의 다른 글
    • LeetCode / Linked List / 328번 / Odd Even Linked List / JS
    • LeetCode / Simulation / 1706번 / Where Will the Ball Fall / JS
    • LeetCode / Linked List / 19번 / Remove Nth Node From End of List / JS
    • LeetCode / String / 43번 / Multiply Strings / JS
    KimMinJun
    KimMinJun

    티스토리툴바