Yu's Coding Garden : leetcode Question: Summary Ranges
Pages Summary Ranges Given a sorted integer array without duplicates, return the summary of its ranges. For example, given Analysis: This is an easy question. Since the ranges are all continuous integers, we just need scan the whole array, compare each element with its previous one, if they are not continuous numbers, the current number must belong a new range. In my code, the start and end of the current range is kept in each iteration, don't forget the case that only one number can become a range and the output format is slight different required in this question. Code(C++): class Solution { public: vectorRead full article from Yu's Coding Garden : leetcode Question: Summary Ranges
No comments:
Post a Comment