1598. Crawler Log Folder
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 72% Topics: Array, String, Stack
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def minOperations(self, logs):
"""
:type logs: List[str]
:rtype: int
"""
result = 0
for log in logs:
if log == "../":
if result > 0:
result -= 1
elif log != "./":
result += 1
return result
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions