qingcheng奕  

2014年1月15日

摘要: http://oj.leetcode.com/problems/longest-consecutive-sequence/起初想的是排序,查了下O(n)的排序算法有计数排序、基数排序、桶排序。后来考虑到数据的范围不知道,并且还有可能是负数,这几种方法都不太适用。之后想到了容器,Map、Set的查找是哈希查找,复杂度为O(1).#include #include #include using namespace std;class Solution {public: unordered_set dict; int findLongestConsective(int num) {... 阅读全文
posted @ 2014-01-15 16:41 qingcheng奕 阅读(128) 评论(0) 推荐(0) 编辑