250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 중첩 점
- 구름톤챌린지
- 귤 고르기
- create-next-app
- ResizeObserver
- 날짜 테스트
- jest
- 자바스크립트
- 연결 요소 제거하기
- mutationobserver
- 통신망분석
- 헤르메스 엔진
- 구름톤
- 테스트 Date
- 최솟갑 구하기
- 과제 진행하기
- Leetcode #javascript #알고리즘 #Algorithms #js
- 프로그래머스
- 구름톤 챌린지
- Jest uuid syntax
- JavaScript
- 리액트네이티브 엔진
- 테이블 해시 함수
- mock date
- Google 애널리틱스
- 리액트네이티브
- nextjs-performance
- 호텔 대실
- Hermes Engine
- nextjs
Archives
- Today
- Total
나만보는개발공부블로그
Reverse Linked List 본문
Given the head of a singly linked list, reverse the list, and return the reversed list.
Example 1:
Input: head = [1,2,3,4,5] Output: [5,4,3,2,1]
Example 2:
Input: head = [1,2] Output: [2,1]
/**
* 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 {ListNode}
*/
var reverseList = function(head) {
let dummy = head;
let reversePrevious = null;
let reverseNext = null;
while(dummy){
reversePrevious = dummy.next;
dummy.next = reverseNext;
reverseNext = dummy;
dummy = reversePrevious;
}
return reverseNext;
};
'Algorithms > leetcode' 카테고리의 다른 글
Valid Palindrome (0) | 2021.03.19 |
---|---|
Implement strStr() (0) | 2021.02.17 |
merge-two-sorted-lists (0) | 2021.02.11 |
Climbing Stair (0) | 2021.02.10 |
Longest Common Prefix (0) | 2021.02.09 |