LeetCode – Summary Ranges (Java)
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->2″,”4->5″,”7”]. Analysis When iterating over the array, two values need to be tracked: 1) the first value of a new range and 2) the previous value in the range. Java Solution public List<String> summaryRanges(int[] … Read more