diff options
Diffstat (limited to 'codechef/SortTheString/main.cpp')
| -rw-r--r-- | codechef/SortTheString/main.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/codechef/SortTheString/main.cpp b/codechef/SortTheString/main.cpp new file mode 100644 index 0000000..8a9897e --- /dev/null +++ b/codechef/SortTheString/main.cpp @@ -0,0 +1,24 @@ +#include<bits/stdc++.h> +#include <regex> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + string s; + cin >> s; + if(is_sorted(s.begin(), s.end())) { + cout << "0" << endl; + } else if (regex_search(s.begin(), s.end(), regex("(10)"))) { + cout << "2" << endl; + } else { + cout << "1" << endl; + } + } +} |
