Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit708fe3e

Browse files
refactor 401
1 parentc50f1ee commit708fe3e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

‎src/main/java/com/fishercoder/solutions/_401.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public List<String> readBinaryWatch(int num) {
2929
List<String>times =newArrayList<>();
3030
for (inth =0;h <12;h++) {
3131
for (intm =0;m <60;m++) {
32-
if (Integer.bitCount(h *60 +m) ==num) {
32+
if (Integer.bitCount(h *64 +m) ==num) {
3333
times.add(String.format("%d:%02d",h,
3434
m));//%02 means to pad this two-digit decimal number on the left with zeroes
3535
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._401;
4+
importjava.util.Arrays;
5+
importorg.junit.BeforeClass;
6+
importorg.junit.Test;
7+
8+
importstaticjunit.framework.TestCase.assertEquals;
9+
10+
publicclass_401Test {
11+
privatestatic_401.Solution1solution1;
12+
13+
@BeforeClass
14+
publicstaticvoidsetup() {
15+
solution1 =new_401.Solution1();
16+
}
17+
18+
@Test
19+
publicvoidtest1() {
20+
assertEquals(
21+
Arrays.asList("0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00",
22+
"8:00"),solution1.readBinaryWatch(1));
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp