File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ package me .ramswaroop .bits ;
2
+
3
+ import java .util .Arrays ;
4
+
5
+ /**
6
+ * Created by IntelliJ IDEA.
7
+ *
8
+ * @author: ramswaroop
9
+ * @date: 6/12/15
10
+ * @time: 3:31 PM
11
+ */
12
+ public class BooleanArrayPuzzle {
13
+
14
+ /**
15
+ * Change 1 to 0 in an array of length 2 containing
16
+ * one 0 and the other either 1 or 0.
17
+ *
18
+ * @param a
19
+ * @return
20
+ */
21
+ public static int [] change1To0InArray (int a []) {
22
+ a [a [1 ]] = a [a [0 ]];
23
+ return a ;
24
+ }
25
+
26
+ public static void main (String a []) {
27
+ System .out .println (Arrays .toString (change1To0InArray (new int []{0 , 0 })));
28
+ System .out .println (Arrays .toString (change1To0InArray (new int []{0 , 1 })));
29
+ System .out .println (Arrays .toString (change1To0InArray (new int []{1 , 0 })));
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments