Class Solution
java.lang.Object
g1501_1600.s1598_crawler_log_folder.Solution
1598 - Crawler Log Folder.<p>Easy</p>
<p>The Leetcode file system keeps a log each time some user performs a <em>change folder</em> operation.</p>
<p>The operations are described below:</p>
<ul>
<li><code>"../"</code> : Move to the parent folder of the current folder. (If you are already in the main folder, <strong>remain in the same folder</strong> ).</li>
<li><code>"./"</code> : Remain in the same folder.</li>
<li><code>"x/"</code> : Move to the child folder named <code>x</code> (This folder is <strong>guaranteed to always exist</strong> ).</li>
</ul>
<p>You are given a list of strings <code>logs</code> where <code>logs[i]</code> is the operation performed by the user at the <code>i<sup>th</sup></code> step.</p>
<p>The file system starts in the main folder, then the operations in <code>logs</code> are performed.</p>
<p>Return <em>the minimum number of operations needed to go back to the main folder after the change folder operations.</em></p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/09/09/sample_11_1957.png" alt="" /></p>
<p><strong>Input:</strong> logs = [“d1/”,“d2/”,“../”,“d21/”,“./”]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> Use this change folder operation “../” 2 times and go back to the main folder.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/09/09/sample_22_1957.png" alt="" /></p>
<p><strong>Input:</strong> logs = [“d1/”,“d2/”,“./”,“d3/”,“../”,“d31/”]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> logs = [“d1/”,“../”,“../”,“../”]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= logs.length <= 10<sup>3</sup></code></li>
<li><code>2 <= logs[i].length <= 10</code></li>
<li><code>logs[i]</code> contains lowercase English letters, digits, <code>'.'</code>, and <code>'/'</code>.</li>
<li><code>logs[i]</code> follows the format described in the statement.</li>
<li>Folder names consist of lowercase English letters and digits.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minOperations
-