HTMLify

LeetCode - Check Distances Between Same Letters - Python
Views: 6 | 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

Comments