관리 메뉴

코딩 공부

코딩 인터뷰 퀘스천 완전 분석 - Remove Linked List Elements 본문

Coding

코딩 인터뷰 퀘스천 완전 분석 - Remove Linked List Elements

Daily Coding 2020. 11. 7. 16:26

[LeetCode] [Easy] 203. Remove Linked List Elements

 

leetcode.com/problems/remove-linked-list-elements/

 

Remove Linked List Elements - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

 

연결된 리스트 특정 노드 삭제하기

 

 

이렇게 연결되어있을때 주어진 값을 가진 노드를 지우고 맨 앞에 노드를 리턴하면 됩니다. 저는 앞쪽 노드를 저장해두면서 같은 숫자가 나올때 현재 노드를 스킵하는 방법으로 코드를 작성했습니다.

 

 

살짝 아쉬운 결과네요..

 

 

그전 노드를 저장해두지 않아서 더 빠르게 나올수 있는것 같네요. 항상 최적화를 생각하는 습관을 들여야 겠어요.

 

 

Comments