Answer: RECUR CLUB Hiring | Interview Question | Off-Campus OA (2023)
Answer · Posted Jun 2026
Approach A number is odd if its last digit is odd. Starting from the end of the string: Find the first odd digit. Return the prefix ending at that position. If no odd digit exists, return an empty string. This ensures the returned prefix is the largest possible odd number. Strategy Traverse the string from right to left. Check whether the current digit is odd. If found, return the substring from index 0 to i. If no odd digit exists, ...
The full answer & interview discussion are available to premium members.
Log in Create a free account