LeetCode: Isomorphic Strings
Problem: https://leetcode.com/problems/isomorphic-strings/description/ Code: class Solution: def map_check(self, txt1: str,txt2: str, char_map: dict)->bool: for i in range(len(txt1)): if txt1[i] not in char_map: ...
Search for a command to run...
Articles tagged with #dsa
Problem: https://leetcode.com/problems/isomorphic-strings/description/ Code: class Solution: def map_check(self, txt1: str,txt2: str, char_map: dict)->bool: for i in range(len(txt1)): if txt1[i] not in char_map: ...
Problem https://leetcode.com/problems/longest-common-prefix/ Code: class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: current_prefix = strs[0] for word in strs: while not word.startswith(current_pre...
Problem: https://leetcode.com/problems/number-of-recent-calls/ Code: class RecentCounter: def __init__(self): self.timestamps = deque() def ping(self, t: int) -> int: self.timestamps.append(t) while self.timestamps[...
Problem: https://leetcode.com/problems/container-with-most-water/description/ Code: class Solution: def maxArea(self, height: List[int]) -> int: left=0 right=len(height)-1 max_area=0 while left<right: ...
Problem: https://leetcode.com/problems/matrix-diagonal-sum/description/ Code: class Solution: def diagonalSum(self, mat: List[List[int]]) -> int: """ Sum of Primary & Seconday elements, not repeating middle element. """ ...
Problem: Running Sum of 1D Array class Solution: def runningSum(self, nums: List[int]) -> List[int]: if len(nums)<=1: return nums new_nums=[] total=0 for num in nums: total+=num ...