Problem Solving/LeetCode(27)
-
[LeeCode] 24. Swap Nodes in Pairs
Leetcode 24. Swap Nodes in Pairs Swap Nodes in Pairs - 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 나의 풀이1 # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def swapPairs(self, head: ListNod..
2021.01.14 -
[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 -
[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 -
[LeetCode] 238. Product of Array Except Self
https://leetcode.com/problems/product-of-array-except-self/ Product of Array Except Self - 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 풀이 from typing import List class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: left = [] right = [] result = [] # 왼쪽 곱셈 ..
2021.01.10