File tree Expand file tree Collapse file tree 5 files changed +144
-0
lines changed
solution/1500-1599/1598.Crawler Log Folder Expand file tree Collapse file tree 5 files changed +144
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,59 @@ func minOperations(logs []string) int {
144
144
}
145
145
```
146
146
147
+ ### ** C**
148
+
149
+ ``` c
150
+ #define max (a,b ) (((a) > (b)) ? (a) : (b))
151
+
152
+ int minOperations (char ** logs, int logsSize) {
153
+ int depth = 0;
154
+ for (int i = 0; i < logsSize; i++) {
155
+ char * log = logs[ i] ;
156
+ if (!strcmp(log, "../")) {
157
+ depth = max(0, depth - 1);
158
+ } else if (strcmp(log, "./")) {
159
+ depth++;
160
+ }
161
+ }
162
+ return depth;
163
+ }
164
+ ```
165
+
166
+ ### **TypeScript**
167
+
168
+ ```ts
169
+ function minOperations(logs: string[]): number {
170
+ let depth = 0;
171
+ for (const log of logs) {
172
+ if (log === '../') {
173
+ depth = Math.max(0, depth - 1);
174
+ } else if (log !== './') {
175
+ depth++;
176
+ }
177
+ }
178
+ return depth;
179
+ }
180
+ ```
181
+
182
+ ### ** Rust**
183
+
184
+ ``` rust
185
+ impl Solution {
186
+ pub fn min_operations (logs : Vec <String >) -> i32 {
187
+ let mut depth = 0 ;
188
+ for log in logs . iter () {
189
+ if log == " ../" {
190
+ depth = 0. max (depth - 1 );
191
+ } else if log != " ./" {
192
+ depth += 1 ;
193
+ }
194
+ }
195
+ depth
196
+ }
197
+ }
198
+ ```
199
+
147
200
### ** ...**
148
201
149
202
```
Original file line number Diff line number Diff line change @@ -131,6 +131,59 @@ func minOperations(logs []string) int {
131
131
}
132
132
```
133
133
134
+ ### ** C**
135
+
136
+ ``` c
137
+ #define max (a,b ) (((a) > (b)) ? (a) : (b))
138
+
139
+ int minOperations (char ** logs, int logsSize) {
140
+ int depth = 0;
141
+ for (int i = 0; i < logsSize; i++) {
142
+ char * log = logs[ i] ;
143
+ if (!strcmp(log, "../")) {
144
+ depth = max(0, depth - 1);
145
+ } else if (strcmp(log, "./")) {
146
+ depth++;
147
+ }
148
+ }
149
+ return depth;
150
+ }
151
+ ```
152
+
153
+ ### **TypeScript**
154
+
155
+ ```ts
156
+ function minOperations(logs: string[]): number {
157
+ let depth = 0;
158
+ for (const log of logs) {
159
+ if (log === '../') {
160
+ depth = Math.max(0, depth - 1);
161
+ } else if (log !== './') {
162
+ depth++;
163
+ }
164
+ }
165
+ return depth;
166
+ }
167
+ ```
168
+
169
+ ### ** Rust**
170
+
171
+ ``` rust
172
+ impl Solution {
173
+ pub fn min_operations (logs : Vec <String >) -> i32 {
174
+ let mut depth = 0 ;
175
+ for log in logs . iter () {
176
+ if log == " ../" {
177
+ depth = 0. max (depth - 1 );
178
+ } else if log != " ./" {
179
+ depth += 1 ;
180
+ }
181
+ }
182
+ depth
183
+ }
184
+ }
185
+ ```
186
+
134
187
### ** ...**
135
188
136
189
```
Original file line number Diff line number Diff line change
1
+ #define max (a ,b ) (((a) > (b)) ? (a) : (b))
2
+
3
+ int minOperations (char * * logs , int logsSize ) {
4
+ int depth = 0 ;
5
+ for (int i = 0 ; i < logsSize ; i ++ ) {
6
+ char * log = logs [i ];
7
+ if (!strcmp (log , "../" )) {
8
+ depth = max (0 , depth - 1 );
9
+ } else if (strcmp (log , "./" )) {
10
+ depth ++ ;
11
+ }
12
+ }
13
+ return depth ;
14
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn min_operations ( logs : Vec < String > ) -> i32 {
3
+ let mut depth = 0 ;
4
+ for log in logs. iter ( ) {
5
+ if log == "../" {
6
+ depth = 0 . max ( depth - 1 ) ;
7
+ } else if log != "./" {
8
+ depth += 1 ;
9
+ }
10
+ }
11
+ depth
12
+ }
13
+ }
Original file line number Diff line number Diff line change
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 ++ ;
8
+ }
9
+ }
10
+ return depth ;
11
+ }
You can’t perform that action at this time.
0 commit comments