Skip to content

Commit d48d511

Browse files
Create LargestGoodInteger.java
1 parent 863f87d commit d48d511

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Strings/LargestGoodInteger.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class LargestGoodInteger {
2+
public String largestGI(String num) {
3+
4+
String str = "";
5+
for(int i = 0; i<=num.length()-3;i++){
6+
if(num.charAt(i)==num.charAt(i+1) && num.charAt(i)==num.charAt(i+2) && str.compareTo(num.substring(i,i+3))<0){
7+
str=num.substring(i,i+3);
8+
}
9+
}
10+
11+
return str;
12+
}
13+
}

0 commit comments

Comments
 (0)