File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* ************
2
+ Problem statement:
3
+ SILVER AND GOLD
4
+
5
+ There are N coins kept in a line.
6
+ Each coin has two sides - one is colored gold
7
+ and the other silver. You can flip two adjacent
8
+ coins any number of times. You need to make
9
+ the gold-colored side of every coin facing up.
10
+ You are given the initial status of coins
11
+ in a binary string s where 1 represents the
12
+ gold side facing up and 0 represents the silver
13
+ side facing up. If it is possible to make the
14
+ gold-colored side of every coin facing up,
15
+ return Yes, otherwise return No
16
+
17
+ Input:
18
+ N = 8, s = "11001100"
19
+ Output:
20
+ Yes
21
+ Explanation:
22
+ Flipping 3rd and 4th coin together and 7th
23
+ and 8th coin together will do the task.
24
+ ********* */
1
25
public class SilverAndGold {
2
26
//Silver and Gold Problem
3
27
public static String flipCoins (int N ,String s ) {
You can’t perform that action at this time.
0 commit comments