Skip to content

Commit c08a096

Browse files
Create 1903-largest-odd-number-in-string.java
1 parent f044231 commit c08a096

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public String largestOddNumber(String num) {
3+
String res = "";
4+
for(int i = num.length()-1; i >= 0; i--){
5+
if(num.charAt(i) % 2 != 0){
6+
res = num.substring(0, i+1);
7+
break;
8+
}
9+
}
10+
return res;
11+
}
12+
}

0 commit comments

Comments
 (0)