1903. Largest Odd Number in String Easy
1/**
2 * [1903] Largest Odd Number in String
3 *
4 * You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists.
5 * A substring is a contiguous sequence of characters within a string.
6 *
7 * Example 1:
8 *
9 * Input: num = "52"
10 * Output: "5"
11 * Explanation: The only non-empty substrings are "5", "2", and "52". "5" is the only odd number.
12 *
13 * Example 2:
14 *
15 * Input: num = "4206"
16 * Output: ""
17 * Explanation: There are no odd numbers in "4206".
18 *
19 * Example 3:
20 *
21 * Input: num = "35427"
22 * Output: "35427"
23 * Explanation: "35427" is already an odd number.
24 *
25 *
26 * Constraints:
27 *
28 * 1 <= num.length <= 10^5
29 * num only consists of digits and does not contain any leading zeros.
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/largest-odd-number-in-string/
35// discuss: https://leetcode.com/problems/largest-odd-number-in-string/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn largest_odd_number(num: String) -> String {
41 String::new()
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_1903() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.