HTMLify
LeetCode - Check Distances Between Same Letters - Python
Views: 312 | Author: abh
1 2 3 4 5 6 | class Solution: def checkDistances(self, s: str, distance: List[int]) -> bool: for l in sorted(set(s)): if distance[ord(l)-97] != s.rfind(l) - s.find(l) - 1: return False return True |