Skip to content

Commit 3565ed8

Browse files
committed
feat: update ts solution to lc problem: No.1598
1 parent 0620cfb commit 3565ed8

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

solution/1500-1599/1598.Crawler Log Folder/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ func minOperations(logs []string) int {
160160

161161
```ts
162162
function minOperations(logs: string[]): number {
163-
let depth = 0;
164-
for (const log of logs) {
165-
if (log === '../') {
166-
depth = Math.max(0, depth - 1);
167-
} else if (log !== './') {
168-
depth++;
163+
let ans = 0;
164+
for (const x of logs) {
165+
if (x === '../') {
166+
ans && ans--;
167+
} else if (x !== './') {
168+
ans++;
169169
}
170170
}
171-
return depth;
171+
return ans;
172172
}
173173
```
174174

solution/1500-1599/1598.Crawler Log Folder/README_EN.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ func minOperations(logs []string) int {
157157

158158
```ts
159159
function minOperations(logs: string[]): number {
160-
let depth = 0;
161-
for (const log of logs) {
162-
if (log === '../') {
163-
depth = Math.max(0, depth - 1);
164-
} else if (log !== './') {
165-
depth++;
160+
let ans = 0;
161+
for (const x of logs) {
162+
if (x === '../') {
163+
ans && ans--;
164+
} else if (x !== './') {
165+
ans++;
166166
}
167167
}
168-
return depth;
168+
return ans;
169169
}
170170
```
171171

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function minOperations(logs: string[]): number {
2-
let depth = 0;
3-
for (const log of logs) {
4-
if (log === '../') {
5-
depth = Math.max(0, depth - 1);
6-
} else if (log !== './') {
7-
depth++;
2+
let ans = 0;
3+
for (const x of logs) {
4+
if (x === '../') {
5+
ans && ans--;
6+
} else if (x !== './') {
7+
ans++;
88
}
99
}
10-
return depth;
10+
return ans;
1111
}

0 commit comments

Comments
 (0)