## satish1987

BAN USER- 4of 4 votes

AnswersThis is one of the interview questions during the Amazon SDE interview. Request your help in providing the solution.

- satish1987 in United States

Question - We are interested in building a special type of sequence. for a given number N, we want to arrange the numbers {1,1,2,2,3,3,... N,N} such that they have the following property.

For each number / in (1,N) there should be exactly / numbers between the first appearance of the number and the second appearance. Below example would clarify further.

Input:

A Single number N for which we want to produce the sequence.

Output:

A space separated list of sequence or NA if there is no possible sequence.

Example Input:

3

Example Output:

2 3 1 2 1 3

Explanation : There is 1 number between 1s(2). There are 2 numbers between the 2's(3 1 ). There are 3 numbers between the 3's(1 2 1 ).| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswerThis is one of the interview questions during the Amazon SDE interview. Request your help in providing the solution.

- satish1987 in United States

Question - We are interested in building a special type of sequence. for a given number N, we want to arrange the numbers {1,1,2,2,3,3,... N,N} such that they have the following property.

For each number / in (1,N) there should be exactly / numbers between the first appearance of the number and the second appearance. Below example would clarify further.

Input:

A Single number N for which we want to produce the sequence.

Output:

A space separated list of sequence or NA if there is no possible sequence.

Example Input:

3

Example Output:

2 3 1 2 1 3

Explanation : There is 1 number between 1s(2). There are 2 numbers between the 2's(3 1 ). There are 3 numbers between the 3's(1 2 1 ).| Report Duplicate | Flag | PURGE

Mathworks SDE1 Algorithm

Thank you so much for the help. Could you please describe the logic with explanation for understanding. Thanks a lot.

- satish1987 August 12, 2015**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

Thank you so much for the help. Could you please describe the logic with explanation for understanding. Thanks a lot.

- satish1987 August 12, 2015