Hackerrank Counting Valleys Solution