generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from ayushcodes0/day20
Day20 solution
- Loading branch information
Showing
1 changed file
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
// Write your code here. | ||
// Write your code here. | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main(){ | ||
int n,x; | ||
cin>>n>>x; | ||
string s; | ||
cin>>s; | ||
for (int i = 0; i<n; i++){ | ||
if(x>0 && s[i] == 'x'){ | ||
x--; | ||
} | ||
else if(x>=0 && s[i] == 'o'){ | ||
x++; | ||
} | ||
|
||
} | ||
cout<<x<<endl; | ||
|
||
|
||
|
||
return 0; | ||
} |