Skip to content

Commit 79fab94

Browse files
authored
Create crawler-log-folder.cpp
1 parent fbb79b7 commit 79fab94

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

C++/crawler-log-folder.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int minOperations(vector<string>& logs) {
7+
int result = 0;
8+
for (const auto& log: logs) {
9+
if (log == "../") {
10+
if (result > 0) {
11+
--result;
12+
}
13+
} else if (log != "./") {
14+
++result;
15+
}
16+
}
17+
return result;
18+
}
19+
};

0 commit comments

Comments
 (0)