Summary ranges challenge

Problem statement
Given a sorted integer array without duplicates, return the summary of its ranges for consecutive numbers.

For example, given [0,1,2,4,5,7], return [0\rightarrow 2,4\rightarrow 5,7].

Solution

 

lucas