King-Dreams-I (Intuit India)
Once upon a time, a King saw a dream, where if his kingdom has good line of tanks, meaning tanks lined up side by side in a certain way, they will become invincible.
Now, since you are the advisor of the king, he has asked you to create a good line of tanks.
There are m types of tanks, numbered 1 through m, and we have infinite amount of tanks for each type.
Come up with a good line of size n tanks. If there are multiple good lines return one which is lexicographically smallest.
A good line is a configuration where tanks lined up in an array and the count of subarrays with only distinct tank types is maximum. e.g {3, 4, 4, 5} contains 6 subarrays with distinct tanks: {3}, {4}, {4}, {5}, {3, 4}, {4, 5}
An array x is lexicographically smaller than an array y if there exists an index i such that xi < yj for all 1 <= j < i. Less formally, at the first index i in which they differ, x[i] < y[i].
Constraints
1 <= n <= 100000
1 <= m <= 10000000
1Example 1
Max subarrays count with distinct tanks for line size 1 is 1. Possible lines - {1}, {2} We choose {1} as it is lexicographically smallest.
2Example 2
The only possible line - {1, 1}
3Example 3
Possible lines: {1, 1}, {1, 2}, {2, 1}, {2, 2} Lines {1, 2} and {2, 1} have max count of subarrays with distinct tanks.
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 1000001 <= m <= 10000000