Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions solution/1500-1599/1598.Crawler Log Folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,31 @@ func minOperations(logs []string) int {

```ts
function minOperations(logs: string[]): number {
let depth = 0;
for (const log of logs) {
if (log === '../') {
depth = Math.max(0, depth - 1);
} else if (log !== './') {
depth++;
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return depth;
return ans;
}
```

#### JavaScript

```ts
function minOperations(logs) {
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return ans;
}
```

Expand Down
30 changes: 23 additions & 7 deletions solution/1500-1599/1598.Crawler Log Folder/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,31 @@ func minOperations(logs []string) int {

```ts
function minOperations(logs: string[]): number {
let depth = 0;
for (const log of logs) {
if (log === '../') {
depth = Math.max(0, depth - 1);
} else if (log !== './') {
depth++;
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return depth;
return ans;
}
```

#### JavaScript

```js
function minOperations(logs) {
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return ans;
}
```

Expand Down
11 changes: 11 additions & 0 deletions solution/1500-1599/1598.Crawler Log Folder/Solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function minOperations(logs) {
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return ans;
}
14 changes: 7 additions & 7 deletions solution/1500-1599/1598.Crawler Log Folder/Solution.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function minOperations(logs: string[]): number {
let depth = 0;
for (const log of logs) {
if (log === '../') {
depth = Math.max(0, depth - 1);
} else if (log !== './') {
depth++;
let ans = 0;
for (const x of logs) {
if (x === '../') {
ans && ans--;
} else if (x !== './') {
ans++;
}
}
return depth;
return ans;
}