Given a sorted array of numbers, return the summary of its ranges.

## Examples
```python
summary_ranges([1, 2, 3, 4]) == ["1->4"]
summary_ranges([1, 1, 1, 1, 1]) == ["1"]
summary_ranges([0, 1, 2, 5, 6, 9]) == ["0->2", "5->6", "9"]
summary_ranges([0, 1, 2, 3, 3, 3, 4, 5, 6, 7]) == ["0->7"]
summary_ranges([0, 1, 2, 3, 3, 3, 4, 4, 5, 6, 7, 7, 9, 9, 10]) == ["0->7", "9->10"]
summary_ranges([-2, 0, 1, 2, 3, 3, 3, 4, 4, 5, 6, 7, 7, 9, 9, 10, 12]) == ["-2", "0->7", "9->10", "12"]
```

Difficulty: introductory

Starter code:

def summary_ranges(nums):
	

Solutions:
def summary_ranges(nums):
    ret, s = [], float('-inf')
    for e, n in zip([s] + nums, nums + [-s]):
        if n - e > 1:
            ret.append(['{}', '{}->{}'][s<e].format(s,e))
            s = n
    return ret[1:]

def summary_ranges(nums):
    if not nums:
        return []
    ranges = []
    first = nums[0]
    for current, previous in zip(nums[1:], nums[:-1]):
        if current - previous not in [0, 1]:
            ranges.append((first, previous))
            first = current
    ranges.append((first, nums[-1]))
    return ["{}->{}".format(a, b) if a!=b else str(a) for a, b in ranges]

def summary_ranges(nums):
    nums.append(float("inf"))
    i, result = nums[0], []
    for j, n in zip(nums, nums[1:]):
        if n - j > 1:
            result.append(str(i) if i == j else f"{i}->{j}")
            i = n
    return result

def summary_ranges(nums):

    result, start = [], float('-inf')
    
    for a, b in zip( [start]+ nums, nums +[-start]):
        if b - a > 1:
            result.append((start, a))
            start = b
            
    return [[f'{a}', f'{a}->{b}'][b>a] for a,b in result[1:]]


def summary_ranges(nums):
    l, index = [[]], 0
    for x in nums:
        if not l[index] or (l[index][-1] + 1) == x:
            l[index].append(x)
        else:
            if l[index] != [x]:
                l.append([x])
                index += 1
    return [] if not nums else [str(x[0]) if len(x)<2 else f"{x[0]}->{x[-1]}" for x in l]

def summary_ranges(nums):
    def f():
        cur = []
        for x in nums:
            if not cur:
                cur = [x]
            elif x == cur[-1] + 1:
                cur[1:] = x,
            elif x != cur[-1]:
                yield cur
                cur = [x]
        if cur:
            yield cur
    return [str(xs[0]) if xs[0] == xs[-1] else f'{xs[0]}->{xs[-1]}' for xs in f()]

def summary_ranges(nums):
    if not nums: return []
    
    r, s, l = [], nums[0], nums[0]
    for n in nums:
        if n - l > 1:
            r.append(str(s)+'->'+str(l) if s != l else str(s))
            s = n
        l = n
    r.append(str(s)+'->'+str(l) if s != l else str(s))
    return r

def summary_ranges(a):
    a,i,li = sorted(set(a), key=a.index),0,[]
    while i < len(a):
        temp = [a[i]] ; i += 1
        while i < len(a) and temp[-1] + 1 == a[i] : temp.append(a[i]) ; i += 1
        li.append(temp)
    return [f"{i[0]}->{i[-1]}" if len(i) > 1 else f"{i[0]}" for i in li]

def summary_ranges(nums):
    i, lst, nums = 0, [], sorted(set(nums))
    while i < len(nums):
        i,j = i+1, i
        while i < len(nums) and nums[i] == nums[i-1]+1: i+= 1
        lst.append( str(nums[j]) if j+1 == i else "{}->{}".format(nums[j], nums[i-1]) )
    return lst