Skip to content

Commit b5ec4d5

Browse files
committed
feat: add js solution to lc problem: No.1598
1 parent 3565ed8 commit b5ec4d5

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ function minOperations(logs: string[]): number {
172172
}
173173
```
174174

175+
#### JavaScript
176+
177+
```ts
178+
function minOperations(logs) {
179+
let ans = 0;
180+
for (const x of logs) {
181+
if (x === '../') {
182+
ans && ans--;
183+
} else if (x !== './') {
184+
ans++;
185+
}
186+
}
187+
return ans;
188+
}
189+
```
190+
175191
#### Rust
176192

177193
```rust

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@ function minOperations(logs: string[]): number {
169169
}
170170
```
171171

172+
#### JavaScript
173+
174+
```js
175+
function minOperations(logs) {
176+
let ans = 0;
177+
for (const x of logs) {
178+
if (x === '../') {
179+
ans && ans--;
180+
} else if (x !== './') {
181+
ans++;
182+
}
183+
}
184+
return ans;
185+
}
186+
```
187+
172188
#### Rust
173189

174190
```rust
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function minOperations(logs) {
2+
let ans = 0;
3+
for (const x of logs) {
4+
if (x === '../') {
5+
ans && ans--;
6+
} else if (x !== './') {
7+
ans++;
8+
}
9+
}
10+
return ans;
11+
}

0 commit comments

Comments
 (0)