Sep-19-2019, 01:54 AM
I don't see a "while" loop in your code. At least, you need to put "while True:" somewhere. You can use negative indexing to get the second element from the tail of a list. Finally, your solution is of O(n) space complexity (n the number of entered numbers); It would be useful if you try to find O(1) solution as well (i.e. without storing all entered numbers to a list).