0
Leetcode Problem 1903. Largest Odd Number in String
1903. Largest Odd Number in String
AI Mock Interview
Leetcode Solutions
Find the Rightmost Odd Digit
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Iterate over the characters of
num
from right to left.
For each character, check if it is an odd digit by casting it to an integer and taking its value mod 2.
If an odd digit is found, return the substring of
num
starting at index 0 and ending with the index of the found odd digit.
If no odd digit is found by the end of the iteration, return an empty string.
Brute Force Search for Largest Odd Substring
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...