Login Register


Legends Reconstruct the queue filter_list
Author
Message
Reconstruct the queue #1
I don't leetcode often so maybe these types of puzzles just aren't ringing my bell, but I have no clue after 10 minutes of thought what exactly is meant by reconstructing the queue. Any thoughts?

https://leetcode.com/problems/queue-reco...scription/

Edit: Came back to it later and figured it out https://sinister.ly/Thread-Legends-Recon...#pid784087
Comment if you have any questions
(This post was last modified: 11-02-2017, 04:05 AM by Nil.)
"If you look for the light, you can often find it. But if you look for the dark, that is all you will ever see.”


Reply

RE: Reconstruct the queue #2
After reading the problem. I think it meant you should order them by height. Highest being the last or vice versa. Sounds fun, but I don't have time. :L I probably forgot how to code anyway. xD
[Image: dHJ4Beo.gif]
Hidden Lesson: Reactions are always instinctive whereas responses are always well thought of.

Reply

RE: Reconstruct the queue #3
(11-02-2017, 02:33 AM)OversouL Wrote: After reading the problem. I think it meant you should order them by height. Highest being the last or vice versa. Sounds fun, but I don't have time. :L I probably forgot how to code anyway.  xD

Not quite. If you look at the example output you can see that the height isn't the determining factor for the order.
"If you look for the light, you can often find it. But if you look for the dark, that is all you will ever see.”


Reply

RE: Reconstruct the queue #4
(11-02-2017, 03:13 AM)God Wrote:
(11-02-2017, 02:33 AM)OversouL Wrote: After reading the problem. I think it meant you should order them by height. Highest being the last or vice versa. Sounds fun, but I don't have time. :L I probably forgot how to code anyway.  xD

Not quite. If you look at the example output you can see that the height isn't the determining factor for the order.

Oh totally ignored it. XD

Perhaps the number of people in front takes priority. If number of people in front is 0 then it should be listed first. If there are more inputs with k = 0 then they are rearranged by height. But also the number of persons in front must be satisfied first. I dunno, it's kinda hard to explain.

I think I could apply the algorithms I learned from my data structures class, but I already forgot. XD
(This post was last modified: 11-02-2017, 03:36 AM by OversouL.)
[Image: dHJ4Beo.gif]
Hidden Lesson: Reactions are always instinctive whereas responses are always well thought of.

Reply

RE: Reconstruct the queue #5
Well just took a break and looked at it again and realized it's fairly simple now. Implementing it isn't so simple but the gist of it is to view the front of the line as the first element. And then it's just arranging them in an order for where each item to the right's k value holds true for it's position.
"If you look for the light, you can often find it. But if you look for the dark, that is all you will ever see.”


Reply







Users browsing this thread: 1 Guest(s)