Largest Odd Number in String

Given a string num representing a large integer, return the largest-valued odd number (as a string) that is a non-empty substring of num, or "" if no odd…

Given a string `num` representing a large integer, return the **largest-valued odd** number (as a string) that is a non-empty substring of `num`, or `""` if no odd integer exists. A substring is a contiguous sequence of characters within a string. **Key insight:** the answer is always a **prefix** of `num` ending at the rightmost odd digit. A longer numeric string that ends with an odd digit is always larger than a shorter one, so you only need to find the rightmost odd digit and return everything from index 0 up to and including that index. Indexing is **0-based**. **Example:** `"1230"` → the rightmost odd digit is `3` at index 2. The prefix `num[0..2]` = `"123"` is the largest odd number.

- `1 <= num.length <= 10^5` - `num` consists only of digits (`0`–`9`). - `num` does not have leading zeros except when `num` itself is `"0"`. - The interactive visualizer accepts at most 40 digits; longer valid judge inputs remain execution-only.

Example 1: input num = "35427"; output 35427. The rightmost odd digit is 7 at index 4. The prefix num[0..4] = "35427" is the answer.

Example 2: input num = "1230"; output 123. The rightmost odd digit is 3 at index 2. The prefix num[0..2] = "123" is the answer.

Category: Strings. Topic: strings. Difficulty: Easy. Patterns: string-processing.