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 #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: ...
Problem: https://leetcode.com/problems/rotate-string/description/ Code: # OPTIMISED class Solution: def rotateString(self, s: str, goal: str) -> bool: return len(s)==len(goal) and goal in (s+s) # BELOW TWO SOLUTIONS NOT (O(N^2)) # class ...
Problem: https://leetcode.com/problems/largest-odd-number-in-string/description/ Code: class Solution: def largestOddNumber(self, num: str) -> str: for i in range(len(num)-1,-1, -1): if int(num[i])%2!=0: return...
https://leetcode.com/problems/length-of-last-word/description/ Code: class Solution: def lengthOfLastWord(self, s: str) -> int: return len(s.strip().split()[-1]) Key Points: Problem in Simple Words We need to return the length of the las...
Problem: https://leetcode.com/problems/sort-the-people/ Code: class Solution: def sortPeople(self, names: List[str], heights: List[int]) -> List[str]: return [name for height, name in sorted(zip(heights, names), reverse=True)] Key Points...