• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2014年9月18日
Leetcode: Search in Rotated Sorted Array II
摘要: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function ... 阅读全文
posted @ 2014-09-18 12:18 neverlandly 阅读(350) 评论(0) 推荐(0)
Leetcode: Search in Rotated Sorted Array
摘要: 根据binary search,每次我们都可以切掉一半的数据,所以算法的时间复杂度是O(logn),空间复杂度是O(1)。 阅读全文
posted @ 2014-09-18 11:38 neverlandly 阅读(322) 评论(0) 推荐(0)
Leetcode: Populating Next Right Pointers in Each Node II
摘要: 层次递进法 复杂度 时间 O(N) 空间 O(1) 阅读全文
posted @ 2014-09-18 07:01 neverlandly 阅读(402) 评论(0) 推荐(0)
Leetcode: Populating Next Right Pointers in Each Node
摘要: 复杂度 时间 O(N) 空间 O(N) 思路 相当于是Level Order遍历二叉树。通过一个Queue来控制每层的遍历,注意处理该层最后一个节点的特殊情况。此方法同样可解第二题。 没想到的方法:因为guarantee了是perfect binary tree 层次递进法 复杂度 时间 O(N) 阅读全文
posted @ 2014-09-18 06:38 neverlandly 阅读(376) 评论(0) 推荐(0)
Summary: Difference between null and empty String
摘要: String s1 = "";means that the emptyStringis assigned tos1. In this case,s1.length()is the same as"".length(), witch will yield0as expected.String s2 =... 阅读全文
posted @ 2014-09-18 06:22 neverlandly 阅读(222) 评论(0) 推荐(0)
Summary: Deep Copy vs. Shallow Copy vs. Lazy Copy
摘要: Object copyAnobject copyis an action in computing where a data object has itsattributescopied to another object of the same data type. Anobjectis a co... 阅读全文
posted @ 2014-09-18 06:13 neverlandly 阅读(578) 评论(0) 推荐(0)
Leetcode: Remove Duplicates from Sorted List II
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-... 阅读全文
posted @ 2014-09-18 04:35 neverlandly 阅读(367) 评论(0) 推荐(0)
Leetcode: Copy List with Random Pointer
摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2014-09-18 03:18 neverlandly 阅读(449) 评论(0) 推荐(0)
Leetcode: Sort List
摘要: 记得Insert Sort List, 那个复杂度是O(N^2)的,这里要求O(nlogn),所以想到merge sort, 需要用到Merge Two Sorted List的方法(我写的merge函数) 第二遍代码:所以mergesort不好写在于它是一个递归里嵌套另一个递归,第一个递归不停地用 阅读全文
posted @ 2014-09-18 00:31 neverlandly 阅读(373) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3