2211. Count Collisions on a Road

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2211

class Solution:
    def countCollisions(self, directions: str) -> int:
        d = directions.lstrip('L').rstrip('R')
        return len(d) - d.count('S')