g1501_1600.s1598_crawler_log_folder.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java11 Show documentation
Show all versions of leetcode-in-java11 Show documentation
Java Solution for LeetCode algorithm problems, continually updating
The newest version!
package g1501_1600.s1598_crawler_log_folder;
// #Easy #Array #String #Stack #2022_04_08_Time_0_ms_(100.00%)_Space_42_MB_(81.44%)
public class Solution {
public int minOperations(String[] logs) {
int steps = 0;
for (String log : logs) {
if (log.equals("../")) {
if (steps > 0) {
steps--;
}
} else if (!log.equals("./")) {
steps++;
}
}
return steps;
}
}