Leetcode(21)
-
[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] 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 -
[LeetCode] 561. Array Partition I
https://leetcode.com/problems/array-partition-i/ Array Partition I - 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 class Solution: def arrayPairSum(self, nums: List[int]) -> int: nums.sort(reverse=True) sum = 0 for i in range(1, len(nums), 2): sum += nums[i] return sum 내림차..
2021.01.10 -
[LeetCode] 1. Two Sum
https://leetcode.com/problems/two-sum/ Two Sum - 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 class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: index = [] for i in range(len(nums)): for j in range(i+1, len(nums)): if nums[i] + nums[j] == target:..
2021.01.07 -
[LeetCode] 5. Longest Palindromic Substring
https://leetcode.com/problems/longest-palindromic-substring/ Longest Palindromic Substring - 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 내 풀이 class Solution: def longestPalindrome(self, s: str) -> str: if len(s) < 2 or s[:] == s[::-1]: return s palindrome = [] length = len(s) s..
2021.01.07