Problem Solving(68)
-
[LeetCode] 2. Add Two Numbers
LeetCode 2. Add Two Numbers https://leetcode.com/problems/add-two-numbers/ Add Two Numbers - 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 Solution # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Sol..
2021.01.14 -
[LeetCode] 206. Reverse Linked List
https://leetcode.com/problems/reverse-linked-list/ Reverse Linked List - 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 A linked list can be reversed either iteratively or recursively. Could you implement both? 내 풀이 이게 iteratively 풀이 일것이다. # Definition for singly-linked list. clas..
2021.01.13 -
[LeetCode] 234. Palindrome Linked List
https://leetcode.com/problems/palindrome-linked-list/ Palindrome Linked List - 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 Single Linked List 문제이다. 내 풀이 리스트를 이용한 풀이이다. Deque으로도 가능하다. from typing import List # Definition for singly-linked list. # class ListNode: # def __init__(s..
2021.01.12 -
[자료구조] Double Linked List (이중 연결 리스트) 구현
Double Linked List # Single Linked List class Node: def __init__(self, item, prev=None, next=None): self.item = item self.prev = prev self.next = next class DoubleLinkedList: def __init__(self): self.head = Node(None) self.tail = Node(None, self.head) self.head.next = self.tail self.size = 0 def list_size(self): return self.size def is_empty(self): if self.size != 0: return False else: return Tr..
2021.01.11 -
[자료구조] Single Linked List (단순 연결 리스트) 구현
Single Linked List (단순 연결 리스트) 파이썬으로 구현 해 보았다. # Single Linked List class Node: def __init__(self, item, next=None): self.item = item self.next = next class SingleLinkedList: def __init__(self): self.head = None self.size = 0 def list_size(self): return self.size def is_empty(self): if self.size != 0: return False else: return True def select_node(self, idx): if idx >= self.size: print("Index Er..
2021.01.11 -
[LeetCode] 121. Best Time to Buy and Sell Stock
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - 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 풀이 import collections from typing import Deque from typing import List class Solution: def maxProfit(self, prices: List[int]) -> int: if ..
2021.01.11