作者oin1104 (是oin的說)
標題Re: [閒聊] 每日leetcode
時間2024-07-10 10:34:39
https://leetcode.com/problems/crawler-log-folder
:
: 1598. Crawler Log Folder
:
: 有一log紀錄使用者更改資料夾的操作
:
: 操作有三:
:
: 1 ../:回到父資料夾 假如已在主資料夾 則不變
:
: 2 ./:不變
:
: 3 x/:前往子資料夾x
:
:
: 請回傳完成log的資料夾操作後 回到主資料夾的最小操作
:
思路:
好想跟靈夢做愛喔
```cpp
class Solution {
public:
int minOperations(vector<string>& logs)
{
int len = logs.size();
int n = 0;
for(int i = 0 ; i < len ; i ++)
{
if(logs[i] == "../")
{
if(n>0)n --;
}
else if(logs[i] == "./" )continue;
else n++;
}
return n;
}
};
```
記錄一下
我感覺我這個寒假要拿徽章了
不要不信
--
※ 發信站: 批踢踢實業坊(ptt-website.tw), 來自: 61.230.133.184 (臺灣)
※ 文章網址: https://ptt-website.tw/Marginalman/M.1720578881.A.71B
→ oin1104: 暑假 講錯 07/10 10:34
推 SecondRun: 大師 07/10 10:38
推 sustainer123: 大師 07/10 10:40