---
# System prepended metadata

title: 1903. Largest Odd Number in String
tags: [Leetcode, Easy]

---

# 1903. Largest Odd Number in String
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/largest-odd-number-in-string/description/
## 思路
找到最右边一个奇数
以它结尾的substring就是答案
## Code
```java=
class Solution {
    public String largestOddNumber(String num) {
        for(int i=num.length()-1; i>=0; i--){
            if((num.charAt(i)-'0')%2==1){
                return num.substring(0, i+1);
            }
        }
        return "";
    }
}
```