diff --git a/Problems/Data-structures/Day-04/sol/Vishva Modh/soln1.cpp b/Problems/Data-structures/Day-04/sol/Vishva Modh/soln1.cpp new file mode 100644 index 0000000..4a220c2 --- /dev/null +++ b/Problems/Data-structures/Day-04/sol/Vishva Modh/soln1.cpp @@ -0,0 +1,101 @@ +#include +#include +using namespace std; +typedef unordered_map umii; +typedef unordered_map umll; +typedef unordered_map umci; +typedef vector> vpi; +typedef vector vi; +typedef long long ll; +typedef vector vll; +typedef unordered_map umib; +#define sum(v) accumulate(v.begin(), v.end(), 0) +#define endl '\n' +#define f0(i, n) for(long long i = 0; i < n; i++) +#define f1(i, n) for(long long i = 1; i < n; i++) +#define as(v) sort(v.begin(), v.end()) +#define all(x) (x).begin(), (x).end() +#define pb push_back +template umll frequency(vector &v) {umll freq;for(auto &x:v) freq[x]++; return freq;} +template umci S_frequency(vector &v) {umci freq;for(auto &x:v) freq[x]++; return freq;} +template void input(vector &v){for(auto &x:v)cin>>x;} +ll power(ll x, ll y){ ll res = 1; while (y > 0){ if (y & 1) res = (ll)(res*x); y = y>>1; x = (ll)(x*x); } return res; } +void pvll(const vector &arr){for(auto it : arr){cout << it << " ";}cout << endl;} +void pvi(const vector &arr){for(auto it : arr){cout << it << " ";}cout << endl;} + +//function to check score i will use stack data structure +//time complexity = o(n); + +//submission link :- https://codeforces.com/contest/1997/submission/355833501 + + +ll checkscore(string s) +{ + ll ans=0; + stackst; + + for(ll i=0;i> n; + // make an rbs first + // approach whenever open>0 do it close to make minimum score + + string s; + cin >> s; + + +//-------------CODE-------------- + + ll open=0; + ll close=0; + + for(ll i=0;i0) + { + s[i] = ')'; + open--; + } + } + + cout << checkscore(s) << endl; + + + +} + + +int main(){ + int tt; cin >> tt; while(tt--) +{solve();}; +}