We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce3dd92 commit bf66fffCopy full SHA for bf66fff
SilverAndGold.java
@@ -0,0 +1,37 @@
1
+public class SilverAndGold{
2
+ //Silver and Gold Problem
3
+ public static String flipCoins(int N,String s) {
4
+ // Code here
5
+ int count0, count1;
6
+ count0 = count1 = 0;
7
+ for(int i = 0;i < N;i++){
8
+ int result = Character.compare('0',s.charAt(i));
9
+ if(result == 0){
10
+ count0++;
11
+ }
12
+ else{
13
+ count1++;
14
15
16
+ if(count0%2 == 0){
17
+ return "Yes";
18
19
20
+ return "No";
21
22
23
+ public static void main(String args[]){
24
+
25
+ System.out.println(flipCoins(8,"10010100"));//test case 1
26
+ System.out.println(flipCoins(8,"11001100"));//test case 2
27
+ System.out.println(flipCoins(2,"00"));//test case 2
28
29
30
31
32
33
+}
34
35
36
37
0 commit comments