摘要:
Best: O(N) time, constant space 复杂度 时间 O(N) 空间 O(N) 思路 用一个哈希表记录字符串s中字母到字符串t中字母的映射关系,一个集合记录已经映射过的字母。或者用两个哈希表记录双向的映射关系。这里不能只用一个哈希表,因为要排除egg->ddd这种多对一的映射 阅读全文
posted @ 2015-12-15 11:46
neverlandly
阅读(333)
评论(0)
推荐(0)
摘要:
基本迭代 Time: O(N), Space: O(1) 基本递归 Time: O(N), Space: O(N)递归栈大小 阅读全文
posted @ 2015-12-15 11:15
neverlandly
阅读(267)
评论(0)
推荐(0)
摘要:
Count the number of prime numbers less than a non-negative number, n.Algorithm: The sieve of Eratosthenes,Referring to Summary: Primes0 and 1 are not ... 阅读全文
posted @ 2015-12-15 03:09
neverlandly
阅读(276)
评论(0)
推荐(0)
摘要:
set Dummy node 这题有个重要的follow up,就是在一个环里怎么删除节点: 参考:http://www.cnblogs.com/EdwardLiu/p/5975748.html 阅读全文
posted @ 2015-12-15 02:24
neverlandly
阅读(268)
评论(0)
推荐(0)
摘要:
Given a range [m, n] where 0 maxRange) continue; 9 int mi = (m>>i) & 1;10 int ni = (n>>i) & 1;11 if (mi == 1 && n... 阅读全文
posted @ 2015-12-15 02:14
neverlandly
阅读(217)
评论(0)
推荐(0)
摘要:
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2015-12-15 00:53
neverlandly
阅读(315)
评论(0)
推荐(0)
浙公网安备 33010602011771号