Coding Question 4
Coding Question 4
Context
=======
Imagine there is a line of people waiting to buy tickets at a movie theater.
Someone pulls a fire alarm and the line has to scatter.
Please return the line in its original order. You can assume you receive this
information as a set of people where a person is:
Example
=======
Person #1 has a height of 1, and they see 1 taller person in front of them
Person #2 has a height of 2, and they see 2 taller people in front of them
Person #3 has a height of 3, and they see 0 taller people in front of them
Person #4 has a height of 4, and they see 1 taller person in front of them
Person #5 has a height of 5, and they see 0 taller people in front of them
Lyee’s note:
If you’re shorter than the person in front of you, you can still see multiple
taller people in front of you. Say you’re 5’ tall and there’s a 6’ person in front
of you, and a 5.5’ person in front of them, you can still see 2 people? Why????
@Override
protected Boolean compareTo(Person person){
return this.height - person.height;
}
}