Company: amazon_14feb
Difficulty: medium
The problem asks us to reorder a given binary string `shipmentData` (consisting of '0's and '1's) to form a new string `P`. This `P` is then transformed into a `finalSequence` using a specific process. The goal is to find the `P` that results in the lexicographically maximal `finalSequence`. Let's break down the problem: ## 1. Problem Description Amazon's fulfillment system processes a binary string called `shipmentData` to produce a `finalSequence`. This involves a transformation process: 1. Start with an empty string `finalSequence`. 2. For each character `c` in `shipmentData`, from left to right (index `i` from `0` to `length-1`): a. Append `c` to the `finalSequence`. b. Reverse the entire `finalSequence`. Before this transformation is applied, the `shipmentData` can be reordered (permuted). The task is to find the configuration of `shipmentData` (let's call this permutation `P`) that produces the lexicographically maximal `finalSequence`. A string `A` is considered lexicographicall