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

Commit 7e83f77

Browse files
committed
reformat
Signed-off-by: ashKIK <ashutheprogrammer@gmail.com>
1 parent cf9339d commit 7e83f77

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎biweekly-52/SortingTheSentence.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.Arrays;
2+
import java.util.Comparator;
3+
import java.util.StringJoiner;
4+
5+
public class SortingTheSentence {
6+
7+
public String sortSentence(String s) {
8+
String[] str = s.split(" ");
9+
Arrays.sort(str, Comparator.comparingInt(word -> word.charAt(word.length() - 1)));
10+
StringJoiner res = new StringJoiner(" ");
11+
for (String word : str) {
12+
res.add(word.substring(0, word.length() - 1));
13+
}
14+
return res.toString();
15+
}
16+
}

‎weekly-241/MinimumNumberOfSwapsToMakeTheBinaryStringAlternating.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public int minSwaps(String s) {
3434
if (Math.abs(numOnes - numZeros) > 1) {
3535
return -1;
3636
}
37-
// if the difference is odd, then impossible to make 10101 pattern, make 01010 instead
37+
// if the difference is odd, it is impossible to make 10101 pattern, make 01010 instead
3838
// vice versa
3939
if (countOnes % 2 == 1) {
4040
return countZeros / 2;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /