• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月15日
Leetcode: Isomorphic Strings
摘要: Best: O(N) time, constant space 复杂度 时间 O(N) 空间 O(N) 思路 用一个哈希表记录字符串s中字母到字符串t中字母的映射关系,一个集合记录已经映射过的字母。或者用两个哈希表记录双向的映射关系。这里不能只用一个哈希表,因为要排除egg->ddd这种多对一的映射 阅读全文
posted @ 2015-12-15 11:46 neverlandly 阅读(333) 评论(0) 推荐(0)
Leetcode: Reverse Linked List
摘要: 基本迭代 Time: O(N), Space: O(1) 基本递归 Time: O(N), Space: O(N)递归栈大小 阅读全文
posted @ 2015-12-15 11:15 neverlandly 阅读(267) 评论(0) 推荐(0)
Leetcode: Count Primes
摘要: 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)
Leetcode: Remove Linked List Elements
摘要: set Dummy node 这题有个重要的follow up,就是在一个环里怎么删除节点: 参考:http://www.cnblogs.com/EdwardLiu/p/5975748.html 阅读全文
posted @ 2015-12-15 02:24 neverlandly 阅读(268) 评论(0) 推荐(0)
Leetcode: Bitwise AND of Numbers Range
摘要: 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)
Leetcode: Happy Number
摘要: 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)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3