Can Rearrange Binary String

Amazon interview question: You’re given a binary string and may repeatedly sort any chosen subsequence in place. For an array of same-length patterns containing 0, 1, and ? wildcards, decide for each pattern if some choice of ? and the allowed operation can transform the original string into that target. Output YES/NO per pattern; each check is independent. Ideal for a coding interview problem.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: