11. Container With Most Water (Medium) class Solution: def maxArea(self, height: List[int]) -> int: s, e = 0, len(height)-1 water = 0 while s매번 살아돌아오는 고전문제투포인터로 풀면 아주 쉽다e-s 에 괄호만 빼먹지 않기 Dev/Algorithm 2024.11.12
27. Remove Element (Easy) import sysclass Solution: def removeElement(self, nums: List[int], val: int) -> int: # for _ in range(nums.count(val)): # nums.remove(val) cnt = 0 for i in range(len(nums)): if nums[i]!=val: nums[cnt] = nums[i] cnt+=1 return cnt찾아서 지우는 방법만 생각했는데 아닌 것만 배열에 남겨도 된다 Dev/Algorithm 2024.11.12
290. Word Pattern (Easy) class Solution: def wordPattern(self, pattern: str, s: str) -> bool: d={} words = s.split() seen=set() if len(pattern)!=len(words): return False for i in range(len(pattern)): if pattern[i] in d: if d[pattern[i]]!=words[i]: return False else: if words[i] in seen: .. Dev/Algorithm 2024.11.12