Skip to content

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

+16
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

+1-1
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)