[LeetCode][Python3] 237. Delete Node in a Linked List
2018. 11. 4. 21:33 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/delete-node-in-a-linked-list/
My Solution :
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
"""
node.val = node.next.val
node.next = node.next.next
Comment :
이 문제는 그다지 좋은 문제가 아니라고 보지만, Linked List에서 node를 제거하는 일반적인 접근법을 알려주려 출제한 것 같다.
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 350. Intersection of Two Arrays II (0) | 2018.11.05 |
---|---|
[LeetCode][Python3] 344. Reverse String (0) | 2018.11.05 |
[LeetCode][Python3] 268. Missing Number (0) | 2018.11.04 |
[LeetCode][Python3] 242. Valid Anagram (0) | 2018.11.04 |
[LeetCode][Python3] 217. Contains Duplicate (0) | 2018.11.04 |
[LeetCode][Python3] 204. Count Primes (0) | 2018.11.04 |
[LeetCode][Python3] 202. Happy Number (0) | 2018.11.04 |
[LeetCode][Python3] 191. Number of 1 Bits (0) | 2018.11.04 |
최근에 달린 댓글 최근에 달린 댓글