King-Dreams-I (Intuit India)

Problem Overview

  • Build a “good line” of n tanks using types 1..m.
  • Maximize the number of subarrays containing only distinct types; if ties, return the lexicographically smallest array.
  • Input: n and m; output any one qualifying array; unlimited supply of each type.
  • Constraints: 1 ≤ n ≤ 100000, 1 ≤ m ≤ 10000000.
  • Real-world theme: a king’s tank lineup; Intuit India coding interview problem and interview question.

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: