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

Commit45d7fc9

Browse files
add 1556
1 parent1ab014e commit45d7fc9

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1556|[Thousand Separator](https://leetcode.com/problems/thousand-separator/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1556.java)||Easy|String|
1112
|1551|[Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1551.java)|[:tv:](https://youtu.be/A-i2sxmBqAA)|Medium|Math|
1213
|1550|[Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1550.java)||Easy|Array|
1314
|1545|[Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1545.java)||Medium|String|
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1556 {
4+
publicstaticclassSolution1 {
5+
publicStringthousandSeparator(intn) {
6+
Stringstr =Integer.toString(n);
7+
StringBuildersb =newStringBuilder();
8+
for (inti =str.length() -1,j =1;i >=0;i--,j++) {
9+
sb.append(str.charAt(i));
10+
j++;
11+
if (j %3 ==0) {
12+
sb.append(".");
13+
}
14+
}
15+
Stringresult =sb.reverse().toString();
16+
if (result.charAt(0) =='.') {
17+
result =result.substring(1);
18+
}
19+
returnresult;
20+
}
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._1556;
4+
importorg.junit.BeforeClass;
5+
importorg.junit.Test;
6+
7+
importstaticjunit.framework.TestCase.assertEquals;
8+
9+
publicclass_1556Test {
10+
privatestatic_1556.Solution1solution1;
11+
12+
@BeforeClass
13+
publicstaticvoidsetup() {
14+
solution1 =new_1556.Solution1();
15+
}
16+
17+
@Test
18+
publicvoidtest1() {
19+
assertEquals("987",solution1.thousandSeparator(987));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp