摘要: Q:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is[1, 2, 3, 4]. Return its length:4.Your algorithm should run in O(n) complexity.A:使用Map来处理。对cluster来说,最重要的是上界,下界和长度。对 阅读全文
posted @ 2013-09-17 17:04 summer_zhou 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Q:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.A: 重点是理解变位词的概念及其给所有词打tag:字典序 vector anagrams(vector &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res; ... 阅读全文
posted @ 2013-09-17 10:59 summer_zhou 阅读(217) 评论(0) 推荐(0) 编辑