LeetCode Problems4

🧑🏻‍💻 LeetCode Medium Collections II - 11 Problems 0054. Spiral Matrix / 0739. Daily Temperaturesclass Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: e,s,w,n = [0,1], [1,0], [0,-1], [-1,0] output = [] rows, cols = len(matrix), len(matrix[0]) visited = [[False] * cols for _ in range(rows)] cnt = 0 x, y = 0,0 dirs = [e,s,w,n] dir_i = 0 while True: .. LeetCode Problems/Medium 2024. 10. 31.
🧑🏻‍💻 LeetCode Medium Collections I - 20 Problems 0300. Longest Increasing Subsequence / 0053. Maximum Subarrayclass Solution: def lengthOfLIS(self, nums: List[int]) -> int: length = len(nums) dp = [1]*length for x in range(1,length): for y in range(0,x): if nums[y] class Solution: def maxSubArray(self, nums: List[int]) -> int: ans,curmax=-10001,0 for i in range(len(nums)): .. LeetCode Problems/Medium 2024. 9. 9.
😍 LeetCode Easy Collections II - 15 Problems 0283. Move Zeroes / 0344. Reverse Stringclass Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ length=len(nums) if length != 1: first_encountered = False for x in range(length-1): if nums[x] == 0: if not first_encountered: .. LeetCode Problems/Easy 2024. 9. 2.
😊 LeetCode Easy Collections I - 20 Problems 0001. Two Sum / 0268. Missing Numberclass Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: dct = dict() for i in range(len(nums)): dct[nums[i]] = i for i in range(len(nums)): if (target-nums[i]) in dct: if i!=dct[target-nums[i]]: return [i,dct[target-nums[i]]]class Solution: def missingNumber.. LeetCode Problems/Easy 2024. 8. 5.