LeetCode Weekly Contest 159
問題文
省略
省略
C++に変換後のコードはこちら
#define main dummy_main
{}
#undef main
class Solution {
public:
vector<string> removeSubfolders(vector<string>& S) {
vector<string> res;
set<string> st;
int N = S.size();
sort(S.begin(), S.end());
rep(i,N){
string tmp = S[i];
while(tmp.size()){
rrep(j,tmp.size()) if(tmp[j]=='/') break;
tmp = tmp.substr(0,j);
if(st.count(tmp)) break;
}
if(tmp.size()==0) st.insert(S[i]), res.push_back(S[i]);
}
return res;
}
};
Current time: 2024年04月20日12時35分09秒
Last modified: 2019年11月03日19時41分31秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)