Like..seriously this question is dam easy. When I first read the question and saw the medium tag I was like I must misunderstood the question. But after reading it for several times I'm like, let me just write the code in 1 min and see which case it fails.
6 lines code, one loop one if. Passed the test. Totally doesn't deserve the medium tag.