Programming Questions

Off line minimum question - JavaScript

I do not understand what is meant here by "the E means take out the smallest integer currently in the whole set". For instance the example shows if strArr is ["5","4","6","E","1","7","E","E","3","2"] then your program should return 4,1,5. However, the smallest integers are 1,3 and 2. I am sure I am missing something here, anyone know what this question is asking?
coderbyte.com/editor/Off%20Line%20Minimum:JavaScript

polinab
posted this question on 8/4/16 **|**

1

@polinab, You can think of the array as a queue where elements are read from left to the right and added into a list. Then every time an "E" is encountered, you need to remove the smallest integer currently in the set so far. So for the example you posted, the set initially contains:
[5] then
[5, 4] then
[5, 4, 6]
Then an E is encountered so remove the smallest element => [4]
Now the set is [5, 6] + [1, 7] = [5, 6, 1, 7]
E is encountered again so remove the smallest element from the set resulting in => [4, 1]. Then remove the smallest element again => [4, 1, 5].
No more E's after this so you are done.

mrdaniel

answered on 08/04/16

0

This challenge needs A LOT more clarification.
mrdaniel : when the set is:
[5, 6, 1, 7]
You say :
"E is encountered again so remove the smallest element from the set resulting in => [4, 1]"
How can that be? Remove the smallest integer from [5, 6, 1, 7] should result in
[5, 6, 7] Right??
What am I missing?

d0ppler

answered on 12/13/18

Log in to write an answer.