Untitled

mail@pastecode.io avatar
unknown
plain_text
11 days ago
456 B
3
Indexable
Never
class Solution {
public:
    int minOperations(vector<string>& logs) {
        stack < string > st;
        
        for(int i=0;i<logs.size();i++) {
            if(logs[i] == "./")continue;
            
            if(logs[i] == "../") {
                if(!st.empty()) {
                    st.pop();
                }
            } 
            else {
                st.push(logs[i]);
            }
        }
        
        return st.size();
    }
};
Leave a Comment