g1501_1600.s1598_crawler_log_folder.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g1501_1600.s1598_crawler_log_folder
// #Easy #Array #String #Stack #2023_06_14_Time_150_ms_(92.31%)_Space_35_MB_(100.00%)
class Solution {
fun minOperations(logs: Array): Int {
var steps = 0
for (log in logs) {
if (log == "../") {
if (steps > 0) {
steps--
}
} else if (log != "./") {
steps++
}
}
return steps
}
}