HTMLify
LeetCode - Number of Segments in a String - Python
Views: 332 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 | class Solution: def countSegments(self, s: str) -> int: n = 0 f = True for c in s+" ": if c == " ": if not f: n += 1 f = True else: f = False return n |