FastPrepFastPrep
Problem Brief

King-Dreams-I (Intuit India)

INTERNOA

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

Input
n = 1, m = 2
Output
[1]
Explanation

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

Input
n = 2, m = 1
Output
[1, 1]
Explanation

The only possible line - {1, 1}

3Example 3

Input
n = 2, m = 2
Output
[1, 2]
Explanation

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 <= 100000
1 <= m <= 10000000
public int[] createGoodLineOfTanks(int n, int m) {
    // write your code here
}
Input

n

1

m

2

Output

[1]

Sign in to submit your solution.