HACKERRANK: Almost sorted interval

https://www.hackerrank.com/challenges/almost-sorted-interval