aboutsummaryrefslogtreecommitdiff
path: root/codechef/SortTheString
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/SortTheString')
-rwxr-xr-xcodechef/SortTheString/mainbin0 -> 603200 bytes
-rw-r--r--codechef/SortTheString/main.cpp24
-rw-r--r--codechef/SortTheString/main_input0.txt9
-rw-r--r--codechef/SortTheString/main_output0.txt4
4 files changed, 37 insertions, 0 deletions
diff --git a/codechef/SortTheString/main b/codechef/SortTheString/main
new file mode 100755
index 0000000..a79a94a
--- /dev/null
+++ b/codechef/SortTheString/main
Binary files differ
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;
+ }
+ }
+}
diff --git a/codechef/SortTheString/main_input0.txt b/codechef/SortTheString/main_input0.txt
new file mode 100644
index 0000000..6f6009d
--- /dev/null
+++ b/codechef/SortTheString/main_input0.txt
@@ -0,0 +1,9 @@
+4
+3
+000
+4
+1001
+4
+1010
+6
+010101
diff --git a/codechef/SortTheString/main_output0.txt b/codechef/SortTheString/main_output0.txt
new file mode 100644
index 0000000..1b9ba74
--- /dev/null
+++ b/codechef/SortTheString/main_output0.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+2