File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed
solution/1500-1599/1598.Crawler Log Folder Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -160,15 +160,15 @@ func minOperations(logs []string) int {
160
160
161
161
``` ts
162
162
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 ++ ;
169
169
}
170
170
}
171
- return depth ;
171
+ return ans ;
172
172
}
173
173
```
174
174
Original file line number Diff line number Diff line change @@ -157,15 +157,15 @@ func minOperations(logs []string) int {
157
157
158
158
``` ts
159
159
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 ++ ;
166
166
}
167
167
}
168
- return depth ;
168
+ return ans ;
169
169
}
170
170
```
171
171
Original file line number Diff line number Diff line change 1
1
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 ++ ;
8
8
}
9
9
}
10
- return depth ;
10
+ return ans ;
11
11
}
You can’t perform that action at this time.
0 commit comments