• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅

随笔分类 -  Summary

上一页 1 2 3
Leetcode: Pow(x, n) and Summary: 负数补码总结

摘要:Analysis: Time Complexity: O(LogN) Iterative code: refer to https://discuss.leetcode.com/topic/40546/iterative-log-n-solution-with-clear-explanation N 阅读全文
posted @ 2014-09-20 00:32 neverlandly 阅读(987) 评论(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 阅读(220) 评论(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 阅读(571) 评论(0) 推荐(0)
Leetcode: Binary Tree Postorder Transversal

摘要:难度:70 recursive方法很直接: Iterative 最优做法: pre-order traversal is root-left-right. post-order traversal is left-right-root. We can modify pre-order travers 阅读全文
posted @ 2014-09-15 10:20 neverlandly 阅读(281) 评论(0) 推荐(0)
Leetcode: Binary Tree Inorder Transversal

摘要:recursive 方法: Iterative method: 参考了一下网上的思路,其实就是用一个栈来模拟递归的过程。所以算法时间复杂度也是O(n),空间复杂度是栈的大小O(logn)。 阅读全文
posted @ 2014-09-15 08:49 neverlandly 阅读(414) 评论(0) 推荐(0)
Leetcode: Reorder List && Summary: Reverse a LinkedList

摘要:这是一道比较综合的链表操作的题目,要按照题目要求给链表重新连接成要求的结果。其实理清思路也比较简单,分三步完成:(1)将链表切成两半,也就是找到中点,然后截成两条链表;(2)将后面一条链表进行reverse操作,就是反转过来;(3)将两条链表按顺序依次merge起来。 这几个操作都是我们曾经接触过的 阅读全文
posted @ 2014-09-07 12:07 neverlandly 阅读(475) 评论(0) 推荐(0)
Summary: Binary Search

摘要:Iterative ways: 1 int binarySearch (int[] a, int x) { 2 int low = 0; 3 int high = a.length - 1; 4 int mid; 5 6 while (low x) {12 ... 阅读全文
posted @ 2014-06-27 06:43 neverlandly 阅读(199) 评论(0) 推荐(0)
Leetcode: Single Number

摘要:Analysis: 需求里面要求O(N)时间以及无额外空间,这就排除了使用boolean array, hashmap这些个方法,只能在原数组上进行查找。O(N)基本上就相当于遍历数组. 最好的方法: 第二遍做法: 17行 & 运算符优先等级低于 == 所以一定要打括号 一样的思路另一个做法: 另外 阅读全文
posted @ 2014-06-19 06:37 neverlandly 阅读(315) 评论(0) 推荐(0)
Leetcode: Longest Palindromic Substring && Summary: Palindrome

摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: Analysis: 想到 阅读全文
posted @ 2014-06-17 12:07 neverlandly 阅读(591) 评论(0) 推荐(0)
Summary: Java中函数参数的传递

摘要:函数调用参数传递类型(java)的用法介绍.java方法中传值和传引用的问题是个基本问题,但是也有很多人一时弄不清。(一)基本数据类型:传值,方法不会改变实参的值。 1 public class TestFun { 2 3 public static void testInt(int ... 阅读全文
posted @ 2014-06-12 05:54 neverlandly 阅读(3045) 评论(0) 推荐(0)
Summary: Depth-first Search(DFS)

摘要:There are generally two methods to write DFS algorithm, one is using recursion, another one is using stack. (reference from Wiki Pedia)Pseudocode for ... 阅读全文
posted @ 2014-06-11 02:09 neverlandly 阅读(628) 评论(0) 推荐(0)

上一页 1 2 3
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3