HTMLify
LeetCode - Check Distances Between Same Letters - Python
Views: 144 | Author: abh
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