Skip to content

Commit 3d893f3

Browse files
add 1903
1 parent 74af51d commit 3d893f3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1903|[Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1903.java) ||Easy|Greedy|
1112
|1897|[Redistribute Characters to Make All Strings Equal](https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1897.java) ||Easy|String, Greedy|
1213
|1886|[Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1886.java) ||Easy|Array|
1314
|1880|[Check if Word Equals Summation of Two Words](https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1880.java) ||Easy|String|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1903 {
4+
public static class Solution1 {
5+
public String largestOddNumber(String num) {
6+
for (int i = num.length() - 1; i >= 0; i--) {
7+
if (Integer.parseInt("" + num.charAt(i)) % 2 == 1) {
8+
return num.substring(0, i + 1);
9+
}
10+
}
11+
return "";
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)