File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,12 @@ public static class Solution1 {
25
25
public int maximumSwap (int num ) {
26
26
String numStr = String .valueOf (num );
27
27
int max = num ;
28
- for (int i = 0 ; i < numStr .length ()- 1 ; i ++) {
29
- for (int j = i + 1 ; j < numStr .length (); j ++) {
28
+ for (int i = 0 ; i < numStr .length () - 1 ; i ++) {
29
+ for (int j = i + 1 ; j < numStr .length (); j ++) {
30
30
if (numStr .charAt (i ) < numStr .charAt (j )) {
31
31
StringBuilder sb = new StringBuilder (numStr );
32
- sb .replace (i , i + 1 , String .valueOf (numStr .charAt (j )));
33
- sb .replace (j , j + 1 , String .valueOf (numStr .charAt (i )));
32
+ sb .replace (i , i + 1 , String .valueOf (numStr .charAt (j )));
33
+ sb .replace (j , j + 1 , String .valueOf (numStr .charAt (i )));
34
34
max = Math .max (max , Integer .parseInt (sb .toString ()));
35
35
}
36
36
}
You can’t perform that action at this time.
0 commit comments