Given a corrupted string, recover the original string by removing leading and trailing characters until a valid word is found. A valid word is a word that consists only of letters. If the remaining string is a valid word, return the first valid word found. If the input string contains only non-alphabetic characters, return an empty string.
Explanation: Step-by-step: 1. Remove leading characters '12345' until a valid word is found. 2. The remaining string is 'LOST', which is a valid word. 3. Return the first valid word found.
Explanation: Step-by-step: 1. Remove leading characters '123' until a valid word is found. 2. The remaining string is 'RECOVER123', which is not a valid word. 3. Remove trailing characters '123' until a valid word is found. 4. The remaining string is 'RECOVER', which is a valid word. 5. Return the first valid word found.
Master coding challenges related to Strings and solve the [Backup] Lost in Text: Recovery of a Corrupted String problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak