Expedia | OA | 10feb 2024 | Modify the String

Question · Posted Apr 2026

Problem: Modify the String Objective: Given a string input_str of length n, you must repeatedly remove characters that appear more than once until every character remaining in the string is distinct. Your goal is to return the lexicographically maximum string possible after all deletions. Rules: Choose any character that occurs at least twice. Delete exactly one occurrence of that character. Repeat until all remaining characters are unique. Return the largest possible string in dictionary order. Example Walkthrough: Input: input_str = ...

The full answer & interview discussion are available to premium members.

Log in Create a free account