Company: Amazon_3oct

Difficulty: medium

Problem Statement

Lexicographical String Game Problem Description During a friendly coding contest, two participants, Mira and Jordan, face off in a string-shrinking duel. They are given a string S made up of lowercase English letters. The rules of the duel: Mira and Jordan alternate turns removing exactly one character at a time, with Mira moving first. Play continues until a single character remains in the string. Each player follows a fixed strategy on their turn: Mira's strategy: remove whichever character leaves the lexicographically smallest resulting string. Jordan's strategy: remove whichever character leaves the lexicographically largest resulting string. Simulate the duel and report the single character that remains once all removals are finished, with Mira moving first. Note: Lexicographical order between two strings is determined as follows: Compare the strings character by character, from left to right. Whichever string has the earlier alphabet letter at the first differing position is the

More Amazon_3oct OA questionsInterview experiences