Company: Amazon HackOn
Difficulty: medium
At a tech company's internal hackathon, two engineers, Priya and Dev, face off in a string-shrinking duel. They start from a string S made only of lowercase English letters. The game rules are as follows: Priya and Dev alternate turns removing one character at a time, with Priya moving first. Play continues until the string has been whittled down to a single character. Each engineer follows a fixed strategy when it's their turn: Priya's strategy: Remove whichever character leaves the lexicographically smallest resulting string. Dev's strategy: Remove whichever character leaves the lexicographically largest resulting string. Simulate the whole game, with Priya moving first, and report the single character that remains at the end. Note: Lexicographic order between two strings is defined as follows: Compare the strings character by character, left to right. At the first position where they differ, the string whose character comes earlier in the alphabet is the smaller one. For example, "a