Question: Atlassian Women In Tech 3.0 (16th September 2023 - SET 2 ) | Compliance Crawler | Countvalid passwords | Search Engine | GetMaximum Power
0
Entering edit mode

0
Entering edit mode

Q1 . 

#include<bits/stdc++.h>
using namespace std;

int solve(vector<string>&v){
    
    int ans=0;
    
    int n=v.size();
    
    for(int i=0;i<n;i++){
        string x=v[i];
        if(x=="../"){
            ans=ans-1;
        }
        else if(x=="./"){
            ans=ans+0;
        }
        else if(x[0]!='.'){
            ans=ans+1;
        }
    }
    
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<string>v(n);
    
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    
    int ans=solve(v);
    
    cout << ans << endl;
}

 

ADD COMMENTlink 15 months ago Snax • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts