본문 바로가기
반응형

Problem Solving/리트코드44

[리트코드 leetcode] 2. Add Two Numbers 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 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: Li.. 2021. 4. 12.
[리트코드 leetcode] 206. Reverse Linked List 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 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, .. 2021. 4. 12.
[리트코드 leetcode] 234. Palindrome Linked List 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 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome.. 2021. 4. 12.
[리트코드 leetcode] 121. Best Time to Buy and Sell Stock 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 class Solution: def maxProfit(self, prices: List[int]) -> int: max_profit = 0 sum = 0 for i in range(1, len(prices)): sum = max(sum+prices[i]-pri.. 2021. 4. 12.
[리트코드 leetcode] 238. Product of Array Except Self 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 class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: output = [] left = 1 right = 1 for i in range(len(nums)): output.append(left.. 2021. 4. 12.
[리트코드 leetcode] 561. Array Partition I 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 class Solution: def arrayPairSum(self, nums: List[int]) -> int: nums.sort() sum =0 for i in range(0,len(nums),2): sum +=nums[i] return sum 2021. 4. 12.
반응형