opentechschool-zurich / 30-min-exercises

30 minute long exercises for the OpenTechSchool Co-Learning in Zurich
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

sort people in a park, but not the trees #13

Open aoloe opened 3 months ago

aoloe commented 3 months ago

Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall!

Example

For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be solution(a) = [-1, 150, 160, 170, -1, -1, 180, 190].