Tap here to switch tabs
Problem
Submissions

Problem: Crawler Log Folder

med
30 min
Try to solve the Crawler Log Folder problem.

Statement

The file system records crawler log operations for navigating directories. Initially, you begin in the main folder.

You are given an array of strings logs, where logs[i] represents the operation performed at step ii:

  • "../": Navigate up to the parent folder of the current directory. If you are already at the main folder, remain where you are.

  • "./": Remain in the current directory.

  • "x/": Navigate into the child folder named x (which is guaranteed to exist).

Return the minimum number of operations required to navigate back to the main folder after processing all the logs.

Constraints:

  • 1≤1 \leq logs.length ≤103\leq 10^3

  • 2≤2 \leq logs[i].length ≤10\leq 10

  • logs[i] contains lowercase English letters, digits, '.', and '/'

  • logs[i] follows the specified format

  • Folder names consist of lowercase English letters and digits

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Crawler Log Folder

med
30 min
Try to solve the Crawler Log Folder problem.

Statement

The file system records crawler log operations for navigating directories. Initially, you begin in the main folder.

You are given an array of strings logs, where logs[i] represents the operation performed at step ii:

  • "../": Navigate up to the parent folder of the current directory. If you are already at the main folder, remain where you are.

  • "./": Remain in the current directory.

  • "x/": Navigate into the child folder named x (which is guaranteed to exist).

Return the minimum number of operations required to navigate back to the main folder after processing all the logs.

Constraints:

  • 1≤1 \leq logs.length ≤103\leq 10^3

  • 2≤2 \leq logs[i].length ≤10\leq 10

  • logs[i] contains lowercase English letters, digits, '.', and '/'

  • logs[i] follows the specified format

  • Folder names consist of lowercase English letters and digits