Create Array Generator Service

Problem Overview

  • Find the lexicographically largest sequence S in exactly m steps.
  • Inputs: arr of positive integers, state string of '0'/'1' availability, and m; S starts empty.
  • Each step, choose an available arr[i] to append; then blocked indices with a left available neighbor become available.
  • Output: sequence S of length m; lexicographic order compares elements left to right.
  • Real-world: array generator service for testers; an Amazon coding interview interview question/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: