aboutsummaryrefslogtreecommitdiff
path: root/codechef/SortTheString/main.cpp
blob: 8a9897e8ed37d4cf12a179af4fbd6334b1c8d015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
    }
	}
}