-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChefAndColoring.java
More file actions
43 lines (40 loc) · 1.16 KB
/
ChefAndColoring.java
File metadata and controls
43 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package problems.codechef;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by hardCode on 4/8/2016.
*/
public class ChefAndColoring {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t,n;
char s[];
t=Integer.parseInt(br.readLine());
while(t-->0){
n=Integer.parseInt(br.readLine());
s=br.readLine().toCharArray();
int r,g,b;
r=0;g=0;b=0;
for (int i = 0; i < n; i++) {
switch (s[i]){
case 'R':
r++;
break;
case 'G':
g++;
break;
case 'B':
b++;
break;
default:
break;
}
}
System.out.println(n-max(r,g,b));
}
}
private static int max(int r, int g, int b) {
return (r>=b && r>=g?r:((b>=g && b>=r)?b:g));
}
}