` ````
```

Loading Question ...

Given two integers `n`

and `k`

, you need to construct a list which contains `n`

different positive integers ranging from `1`

to `n`

and obeys the following requirement:

Suppose this list is [a_{1}, a_{2}, a_{3}, ... , a_{n}], then the list [|a_{1} - a_{2}|, |a_{2} - a_{3}|, |a_{3} - a_{4}|, ... , |a_{n-1} - a_{n}|] has exactly `k`

distinct integers.

If there are multiple answers, print any of them.

**Example 1:**

Input:n = 3, k = 1Output:[1, 2, 3]Explanation:The [1, 2, 3] has three different positive integers ranging from 1 to 3, and the [1, 1] has exactly 1 distinct integer: 1.

**Example 2:**

Input:n = 3, k = 2Output:[1, 3, 2]Explanation:The [1, 3, 2] has three different positive integers ranging from 1 to 3, and the [2, 1] has exactly 2 distinct integers: 1 and 2.

**Note:**

- The
`n`

and`k`

are in the range 1 <= k < n <= 10^{4}.

Seen this question in a real interview before?

Yes

No

When did you encounter this question?

last week

last month

last 3 month

last 6 month

more than 6 months

other

Which stage?

Online Assessment

Phone Interview

On Campus Interview

Onsite Interview

Don't know

Which company?

Adobe

Aetion

Airbnb

Alibaba

Amazon

Apple

Baidu

Bloomberg

Cloudera

Coursera

Cryptic Studios

Dropbox

eBay

Epic Systems

Expedia

Facebook

Fallible

Games

Gilt Groupe

GoDaddy

Goo

Google

Hedvig

Helix

Houzz

Hulu

Indeed

Intuit

IXL

LinkedIn

LiveRamp

Lyft

MAQ Software

Mathworks

Microsoft

NetEase

Netsuite

Palantir

Palantir Technologies

Pinterest

Pocket Gems

Poynt

Pure

Pure Storage

Rackspace

Radius

Riot

Riot Games

Samsung

Snapchat

Square

Storage

Tencent

TinyCo

Twitter

Two Sigma

Uber

Valve

WAP

Works Applications

Yahoo

Yahoo!

Yelp

Zappos

Zenefits

How can we help you?