Programming Questions

SecondGreatLow instructions not clear

One of the test cases being run on this code is ([80, 80]) and it says that the correct answer is "80 80".
This seems completely wrong given the wording of the instructions. It asks for the second lowest and second greatest. If there is only one value being presented (i.e. the value of 80 being presented twice), then logically there is no second greatest and second lowest number. There is only one number, and it is the greatest and lowest number.
This is also reinforced in the wording of the question when they say that given the array [7, 7, 12, 98, 102] we must disregard one of the 7's in the solution. We aren't looking for the second lowest and second greatest position in the array, but the second greatest and second lowest value in the array. It seems like one or the other must be the case, but not both.
I think this should be corrected.

eraserface
posted this question on 8/4/17 **|**

0

I also think, the instructions should be corrected as eraserface said.
Although the question said, it could get tricky when there are only two elements in the input, the author of tis challenge were probably not referring to the case "[80, 80]", because any array of identical numbers would have an undefined output. E.g. "[80,80,80]" doesn't have a second greatest or second lowest number, since all numbers are equal.

tomiq

answered on 03/06/18

0

The question did say that it could get tricky when there are only two elements in the array. I guess that was meant to indicate that you can't ignore the top/low duplicates in that particular case.

kalgima

answered on 10/30/17

Log in to write an answer.