04 2015 档案

摘要:http://beginnersbook.com/2014/06/difference-between-hashmap-and-hashtable/http://www.importnew.com/7010.html 阅读全文
posted @ 2015-04-28 11:20 世界到处都是小星星 阅读(92) 评论(0) 推荐(0) 编辑
摘要:refhttp://inderpsingh.blogspot.com/2010/03/how-to-find-more-or-better-bugs-12-tips.htmlI copied directlyWell, we know that we do not find all the bugs... 阅读全文
posted @ 2015-04-28 11:19 世界到处都是小星星 阅读(144) 评论(0) 推荐(0) 编辑
摘要:我觉得这个算法比较陌生,对我不是简单题目public class Solution { public boolean isHappy(int n) { // 这个叫“模拟”的算法是什么http://meetqun.com/thread-8853-1-1.html H... 阅读全文
posted @ 2015-04-24 12:54 世界到处都是小星星 阅读(149) 评论(0) 推荐(0) 编辑
摘要:注意有很多地方关于long 和int的处理比如赋值n, d判断是否应该是负数的时候如果写成long n = (long) numerator>0? numerator: -numerator;long d = (long) denominator>0? denominator:-denominato... 阅读全文
posted @ 2015-04-24 12:27 世界到处都是小星星 阅读(290) 评论(0) 推荐(0) 编辑
摘要:Given a string S, find the length of the longest substring T that contains at most two distinct characters.Given S = “eceba”,T is “ece” which its leng... 阅读全文
posted @ 2015-04-24 06:34 世界到处都是小星星 阅读(407) 评论(0) 推荐(0) 编辑
摘要:基础题注意要bug free看清楚细节得public class Solution { public ListNode removeElements(ListNode head, int val) { if(head==null ) return null; Lis... 阅读全文
posted @ 2015-04-24 00:41 世界到处都是小星星 阅读(110) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for a point. * class Point { * int x; * int y; * Point() { x = 0; y = 0; } * Point(int a, int b) { x = a; y = b; } * ... 阅读全文
posted @ 2015-04-23 14:05 世界到处都是小星星 阅读(119) 评论(0) 推荐(0) 编辑
摘要:摘抄自http://www.cnblogs.com/springfor/p/3870801.html“这道题运用位运算的异或。异或是相同为0,不同为1。所以对所有数进行异或,得出的那个数就是single number。初始时先让一个数与0异或,然后再对剩下读数挨个进行异或。这里运用到异或的性质:对于... 阅读全文
posted @ 2015-04-23 11:46 世界到处都是小星星 阅读(146) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/linhuanmars/article/details/20187257http://blog.csdn.net/dongtingzhizi/article/details/8236181塞翁失马焉知非福---4/22/2014 阅读全文
posted @ 2015-04-23 11:16 世界到处都是小星星 阅读(185) 评论(0) 推荐(0) 编辑
摘要:refhttp://www.cnblogs.com/springfor/p/3874667.html高亮处"如果一个sorted word是在HashMap里面存在过的,说明这个词肯定是个变形词,除了把这个词加入到返回结果中,还需要把之前第一个存进HashMap里面的value存入result中。"... 阅读全文
posted @ 2015-04-23 04:50 世界到处都是小星星 阅读(142) 评论(0) 推荐(0) 编辑
摘要:经典题refhttp://blog.csdn.net/u011095253/article/details/9158473public class Solution { public ArrayList solveNQueens(int n) { ArrayList res = ... 阅读全文
posted @ 2015-04-22 11:30 世界到处都是小星星 阅读(122) 评论(0) 推荐(0) 编辑
摘要:最后一个block部分不一样,此外,helper最后的return true要想一想,小莹子的解释很好“对整个棋盘所有'.'都填完了,那么就可以返回true了。”public class Solution { public void solveSudoku(char[][] board) { ... 阅读全文
posted @ 2015-04-22 08:29 世界到处都是小星星 阅读(116) 评论(0) 推荐(0) 编辑
摘要:最后一个循环的问题比较值得学习,本质是n皇后public class Solution { public boolean isValidSudoku(char[][] board) { //http://blog.csdn.net/linhuanmars/article/deta... 阅读全文
posted @ 2015-04-22 07:48 世界到处都是小星星 阅读(111) 评论(0) 推荐(0) 编辑
摘要:压力太大了,这道题先不做了public class Solution { public String minWindow(String S, String T) { // 讲解http://articles.leetcode.com/2010/11/finding-minimum... 阅读全文
posted @ 2015-04-22 04:53 世界到处都是小星星 阅读(242) 评论(0) 推荐(0) 编辑
摘要:滑动窗口,但是很繁琐 public class Solution { public ArrayList findSubstring(String S, String[] L) { //http://www.cnblogs.com/springfor/p/3872516.html ... 阅读全文
posted @ 2015-04-21 07:43 世界到处都是小星星 阅读(142) 评论(0) 推荐(0) 编辑
摘要:经典问题,可以把周边都做了,详见ref http://blog.csdn.net/linhuanmars/article/details/19949159public class Solution { public int lengthOfLongestSubstring(String s) ... 阅读全文
posted @ 2015-04-20 12:21 世界到处都是小星星 阅读(98) 评论(0) 推荐(0) 编辑
摘要:题目看不到,所以网上搜刮http://www.danielbit.com/blog/puzzle/leetcode/leetcode-missing-ranges学习了一下public class Solution { public List findMissingRanges(int[] v... 阅读全文
posted @ 2015-04-20 07:23 世界到处都是小星星 阅读(126) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public void rotate(int[] nums, int k) { if(nums==null||nums.length<2||k<1) return; int n = nums.length; ... 阅读全文
posted @ 2015-04-20 05:33 世界到处都是小星星 阅读(97) 评论(0) 推荐(0) 编辑
摘要:很有趣的一个算法,不过好像除此之外用处不大ref http://www.geeksforgeeks.org/majority-element/public int majorityElement(int[] num) { if(num.length<3) return num[0]; ... 阅读全文
posted @ 2015-04-19 13:12 世界到处都是小星星 阅读(137) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int findPeakElement(int[] num) { // binary search http://siddontang.gitbooks.io/leetcode-solution/content/arr... 阅读全文
posted @ 2015-04-19 13:01 世界到处都是小星星 阅读(132) 评论(0) 推荐(0) 编辑
摘要:之前一步一步存的方法略复杂啊,其实直接二分扔就可以咯这里直接给个II的解法,和I多个冗余挪位的判断public class Solution { public int findMin(int[] nums) { int min = nums[0]; int l=0,... 阅读全文
posted @ 2015-04-19 12:42 世界到处都是小星星 阅读(90) 评论(0) 推荐(0) 编辑
摘要:总结帖http://blog.csdn.net/linhuanmars/article/details/39366817code 参考帖http://www.cnblogs.com/springfor/p/3869981.htmlhttp://blog.csdn.net/linhuanmars/ar... 阅读全文
posted @ 2015-04-19 11:46 世界到处都是小星星 阅读(121) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int maxProfit(List prices) { // http://blog.csdn.net/linhuanmars/article/details/23236995 if(prices==n... 阅读全文
posted @ 2015-04-18 12:42 世界到处都是小星星 阅读(224) 评论(0) 推荐(0) 编辑
摘要:这几道题最好连着做, 模式就是loc 和global比,难点在于求出loc,咦,我做过这个梦吔I 只能交易一次,那么loc就和0比 loc = max(loc+diff, 0)为啥是loc+当天diff呢?比如 1,2,4, 1买进,2-1的差价在loc里存着,到了4 的时候4和1 的差价=4-2 ... 阅读全文
posted @ 2015-04-18 11:52 世界到处都是小星星 阅读(108) 评论(0) 推荐(0) 编辑
摘要:还是细节容易错画个图11 21 2 31 2 3 4很容易就出来了额public class Solution { public int minimumTotal(List> triangle) { int m = triangle.size() ; if(m==1... 阅读全文
posted @ 2015-04-18 11:24 世界到处都是小星星 阅读(140) 评论(0) 推荐(0) 编辑
摘要:想清楚了,安排好细节不难public class Solution { public ArrayList> generate(int numRows) { ArrayList> res = new ArrayList>(); if(numRows tmp = new... 阅读全文
posted @ 2015-04-18 05:07 世界到处都是小星星 阅读(126) 评论(0) 推荐(0) 编辑
摘要:跟另一道题一样,不多说了public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { // post就是pre的近似倒过来 if(inorder==null||... 阅读全文
posted @ 2015-04-18 03:39 世界到处都是小星星 阅读(121) 评论(0) 推荐(0) 编辑
摘要:refhttp://www.cnblogs.com/springfor/p/3884034.html以下解释摘抄自 爱做饭的小莹子“题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:Yo... 阅读全文
posted @ 2015-04-18 01:23 世界到处都是小星星 阅读(155) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public void merge(int A[], int m, int B[], int n) { if(B==null||A==null) return; int ia=m-1,ib=n-1, len = A.l... 阅读全文
posted @ 2015-04-17 13:44 世界到处都是小星星 阅读(101) 评论(0) 推荐(0) 编辑
摘要:ref // http://www.cnblogs.com/springfor/p/3869492.html // http://blog.csdn.net/linhuanmars/article/details/24444491//https://leetcode.com/probl... 阅读全文
posted @ 2015-04-17 13:25 世界到处都是小星星 阅读(137) 评论(0) 推荐(0) 编辑
摘要:以下全部抄自“李二娃的博客”,地址http://www.cnblogs.com/lichen782/p/leetcode_Largest_Rectangle_in_Histogram.html说的超详细超有画面感,多谢作者的解释!==========羞羞的引用转载开始==============16... 阅读全文
posted @ 2015-04-17 11:36 世界到处都是小星星 阅读(175) 评论(0) 推荐(0) 编辑
摘要:跟1 差不多,就是多了个一旦相等,就挪边缘的条件, 参考http://blog.csdn.net/linhuanmars/article/details/20588511public class Solution { public boolean search(int[] A, int tar... 阅读全文
posted @ 2015-04-17 10:11 世界到处都是小星星 阅读(124) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int removeDuplicates(int[] A) { //http://needjobasap.blogspot.com/2014/01/remove-duplicates-from-sorted-array... 阅读全文
posted @ 2015-04-17 07:06 世界到处都是小星星 阅读(67) 评论(0) 推荐(0) 编辑
摘要:对于我来说 这种dfs之类的题目还是挺有难度的,尤其是各种条件和设计要想清楚, dfs经典题目,尤其是最后要退一步,高亮处public class Solution { public boolean exist(char[][] board, String word) { if(... 阅读全文
posted @ 2015-04-17 04:20 世界到处都是小星星 阅读(196) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public ArrayList> subsetsWithDup(int[] num) { ArrayList> res = new ArrayList>(); res.add(new ArrayList()); ... 阅读全文
posted @ 2015-04-16 12:30 世界到处都是小星星 阅读(110) 评论(0) 推荐(0) 编辑
摘要:这道题虽然不用到helper,但是却是那一路的参考code 包括有helper的http://blog.csdn.net/linhuanmars/article/details/24286377public class Solution { public ArrayList> subsets(... 阅读全文
posted @ 2015-04-16 11:55 世界到处都是小星星 阅读(191) 评论(0) 推荐(0) 编辑
摘要:三个指针,就是比较容易糊涂,要想清楚public class Solution { public void sortColors(int[] A) { if(A==null || A.length0 && A[p2]==2){ p2--; } ... 阅读全文
posted @ 2015-04-16 11:05 世界到处都是小星星 阅读(131) 评论(0) 推荐(0) 编辑
摘要:这道题有两种解法,第一种最好想吧,2次两分法,第二种是维度变换详细解释refhttp://www.cnblogs.com/springfor/p/3857959.htmlpublic class Solution { public boolean searchMatrix(int[][] ma... 阅读全文
posted @ 2015-04-16 06:19 世界到处都是小星星 阅读(105) 评论(0) 推荐(0) 编辑
摘要:和感染列岛那道题有点共鸣http://www.cnblogs.com/jiajiaxingxing/p/4405731.html这道题就是细节比较多吧code ganker 的总结http://blog.csdn.net/linhuanmars/article/details/39248597pub... 阅读全文
posted @ 2015-04-16 05:00 世界到处都是小星星 阅读(132) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public String multiply(String num1, String num2) { if(num1==null || num2==null || num1.length()*num2.length()==0) re... 阅读全文
posted @ 2015-04-16 03:14 世界到处都是小星星 阅读(108) 评论(0) 推荐(0) 编辑
摘要:都还好吧,就是细节要想清楚,简单public class Solution { public String addBinary(String a, String b) { if(a==null) return b; if(b==null) return a; ... 阅读全文
posted @ 2015-04-15 13:28 世界到处都是小星星 阅读(116) 评论(0) 推荐(0) 编辑
摘要:总结数据处理帖子http://blog.csdn.net/linhuanmars/article/details/39046243这道题看似简单,但是有个优化必须要考虑到,就是如果没有进位,则应该立即返回public class Solution { public int[] plusOne(... 阅读全文
posted @ 2015-04-15 07:41 世界到处都是小星星 阅读(109) 评论(0) 推荐(0) 编辑
摘要:主要是细节和把握一位数组的能力public class Solution { public int minPathSum(int[][] grid) { if(grid==null || grid.length==0 || grid[0].length==0) return 0;... 阅读全文
posted @ 2015-04-15 06:13 世界到处都是小星星 阅读(150) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { if(obstacleGrid == null || obstacleGrid.length==0 || ob... 阅读全文
posted @ 2015-04-15 04:38 世界到处都是小星星 阅读(90) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-04-15 03:31 世界到处都是小星星 阅读(130) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public ArrayList insert(ArrayList intervals, Interval newInterval) { ArrayList res = new ArrayList(); for(Int... 阅读全文
posted @ 2015-04-15 01:30 世界到处都是小星星 阅读(118) 评论(0) 推荐(0) 编辑
摘要:怎么写comparator是要会的public class Solution { public ArrayList merge(ArrayList intervals) { if(intervals==null || intervals.size() res = new Arra... 阅读全文
posted @ 2015-04-15 00:49 世界到处都是小星星 阅读(138) 评论(0) 推荐(0) 编辑
摘要:details killpublic class Solution { public ArrayList spiralOrder(int[][] matrix) { ArrayList res = new ArrayList(); if(matrix==null |... 阅读全文
posted @ 2015-04-14 12:20 世界到处都是小星星 阅读(147) 评论(0) 推荐(0) 编辑
摘要:主要是boundary的条件public class Solution { public void rotate(int[][] matrix) { if(matrix==null || matrix.length==0 || matrix[0].length==0) retur... 阅读全文
posted @ 2015-04-14 12:00 世界到处都是小星星 阅读(97) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int maxProduct(int[] A) { int res = A[0]; // max is local max, res is global max int tmax = res, tmin ... 阅读全文
posted @ 2015-04-14 11:31 世界到处都是小星星 阅读(96) 评论(0) 推荐(0) 编辑
摘要:refhttp://blog.csdn.net/linhuanmars/article/details/21314059DP经典题目,关于怎么动首尾部分,ref说的很明白public class Solution { public int maxSubArray(int[] A) { ... 阅读全文
posted @ 2015-04-14 10:52 世界到处都是小星星 阅读(100) 评论(0) 推荐(0) 编辑
摘要:Jump IGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your ... 阅读全文
posted @ 2015-04-14 10:28 世界到处都是小星星 阅读(137) 评论(0) 推荐(0) 编辑
摘要:主要是思想,坐标和值什么的容易搞混public class Solution { public int firstMissingPositive(int[] A) { for(int i=0; i0 && A[i]<=A.length && A[i] != A[A[i]-1] )... 阅读全文
posted @ 2015-04-14 07:40 世界到处都是小星星 阅读(108) 评论(0) 推荐(0) 编辑
摘要:比较典型的helper的题目,现在我还搞不太清楚dfs之类的,只能用helper来统称了,你明白那个调调就行public class Solution { public ArrayList> combinationSum(int[] candidates, int target) { ... 阅读全文
posted @ 2015-04-14 06:59 世界到处都是小星星 阅读(136) 评论(0) 推荐(0) 编辑
摘要:二分,多设立一个返回条件变可以继承二分法ublic class Solution { public int searchInsert(int[] A, int target) { int l = 0, r = A.length-1; while(lt... 阅读全文
posted @ 2015-04-14 06:25 世界到处都是小星星 阅读(151) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int[] searchRange(int[] A, int target) { int[] res = {-1, -1}; if(A==null || A.length<1) return res; ... 阅读全文
posted @ 2015-04-14 05:35 世界到处都是小星星 阅读(139) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int search(int[] A, int target) { if(A==null || A.length==0) return -1; int l = 0; i... 阅读全文
posted @ 2015-04-13 09:10 世界到处都是小星星 阅读(127) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int removeElement(int[] A, int elem) { if(A==null||A.length<1) return 0; // same http://www.cnblogs.co... 阅读全文
posted @ 2015-04-10 13:18 世界到处都是小星星 阅读(114) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public int removeDuplicates(int[] A) { if(A==null || A.length==0) return 0; // 巧妙的做法http://www.cnblogs.com/sp... 阅读全文
posted @ 2015-04-10 12:59 世界到处都是小星星 阅读(76) 评论(0) 推荐(0) 编辑
摘要:public int maxArea(int[] height) { //http://blog.csdn.net/linhuanmars/article/details/21145429 贪心算法要看看 if(height==null || height.len... 阅读全文
posted @ 2015-04-10 12:22 世界到处都是小星星 阅读(96) 评论(0) 推荐(0) 编辑
摘要:感觉和Container With Most Water很像,这里有个问题,如果让球最大的坑,怎么做呢?还有candy那道题,好像都是这种双扫系列的refhttp://fisherlei.blogspot.com/2013/01/leetcode-trapping-rain-water.html双扫... 阅读全文
posted @ 2015-04-10 11:32 世界到处都是小星星 阅读(137) 评论(0) 推荐(0) 编辑
摘要:答案部分完全借鉴http://www.cnblogs.com/springfor/p/3861890.html以下是摘抄:“爱做饭的小莹子”题目:There are two sorted arrays A and B of size m and n respectively. Find the me... 阅读全文
posted @ 2015-04-10 10:23 世界到处都是小星星 阅读(183) 评论(0) 推荐(0) 编辑
摘要:很简单一道题,就是细节容易出错,必然是二分才有nlogn的速度public class Solution { public ListNode sortList(ListNode head) { // 跟merge sort 一模一样 http://www.cnblogs.com/... 阅读全文
posted @ 2015-04-10 06:23 世界到处都是小星星 阅读(149) 评论(0) 推荐(0) 编辑
摘要:原题解法超屌: ref http://blog.csdn.net/u012162613/article/details/41560337 public ListNode getIntersectionNode(ListNode headA, ListNode headB) { if(... 阅读全文
posted @ 2015-04-10 04:17 世界到处都是小星星 阅读(116) 评论(0) 推荐(0) 编辑
摘要:容易出错的点1 不是原位排序,惊讶!!2 要重新定位pre!!public class Solution { public ListNode insertionSortList(ListNode head) { // 想清楚怎么插入就很简单啦 if(head==nu... 阅读全文
posted @ 2015-04-09 13:06 世界到处都是小星星 阅读(95) 评论(0) 推荐(0) 编辑
摘要://t 牵引拔出元素cur.next,后面的位置,为后面连起来用// p2 牵引将要插入元素后面的位置,为后面连起来用public void reorderList(ListNode head) { if(head==null || head.next==null || head.ne... 阅读全文
posted @ 2015-04-09 12:51 世界到处都是小星星 阅读(155) 评论(0) 推荐(0) 编辑
摘要:写了无数次,今天终于自己想明白了,但是好像还是记住后明白的plotting tool:http://flowchart.com/public class Solution { public ListNode detectCycle(ListNode head) { if(head... 阅读全文
posted @ 2015-04-09 05:07 世界到处都是小星星 阅读(103) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public boolean hasCycle(ListNode head) { if(head==null || head.next==null) return false; ListNode walk = head... 阅读全文
posted @ 2015-04-09 04:33 世界到处都是小星星 阅读(79) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public RandomListNode copyRandomList(RandomListNode head) { //http://www.cnblogs.com/springfor/p/3864457.html ... 阅读全文
posted @ 2015-04-09 03:55 世界到处都是小星星 阅读(104) 评论(0) 推荐(0) 编辑
摘要:今天出来的新题,已经有大神出结果了,刚开始看还没看懂,就是dfs + 二维渲染 图http://www.cnblogs.com/easonliu/p/4402077.htmlpublic class Solution { public int numIslands(char[][] grid)... 阅读全文
posted @ 2015-04-09 00:39 世界到处都是小星星 阅读(343) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public TreeNode sortedListToBST(ListNode head) { if(head==null) return null; int len = 0; ListNode t =... 阅读全文
posted @ 2015-04-08 13:00 世界到处都是小星星 阅读(107) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public ListNode partition(ListNode head, int x) { if(head==null) return head; ListNode h = new ListNode(-1); ... 阅读全文
posted @ 2015-04-08 12:31 世界到处都是小星星 阅读(175) 评论(0) 推荐(0) 编辑
摘要:和I 比起来其实很不一样,反而很类似于linkedlist reverse,不断的看pre.next的东西,我自己想了好久,开始用三个指针,完全糊涂,还是退回到原来的code,才明了public class Solution { public ListNode deleteDuplicates... 阅读全文
posted @ 2015-04-08 10:22 世界到处都是小星星 阅读(77) 评论(0) 推荐(0) 编辑
摘要:看了别人讨论,双指针比较方便http://www.cnblogs.com/springfor/p/3862042.htmlpublic class Solution { public ListNode deleteDuplicates(ListNode head) { if(he... 阅读全文
posted @ 2015-04-08 03:13 世界到处都是小星星 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.小细节容易... 阅读全文
posted @ 2015-04-08 01:32 世界到处都是小星星 阅读(95) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public ArrayList rightSideView(TreeNode root) { // 层遍历,利用queue http://bookshadow.com/weblog/2015/04/03/leetcode-bina... 阅读全文
posted @ 2015-04-08 00:49 世界到处都是小星星 阅读(109) 评论(0) 推荐(0) 编辑
摘要:折腾出来比较费劲,但是巩固了linked list reverse的概念如果有 pre -> 1 ->2 ->3 ->4 ->end返回的reverse是 原来的pre.next 也就是最后reversed 了以后的list: pre ->4 ->3 ->2 ->1 ->end的那个1,在这里,re... 阅读全文
posted @ 2015-04-07 11:01 世界到处都是小星星 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-04-07 10:40 世界到处都是小星星 阅读(109) 评论(0) 推荐(0) 编辑
摘要:关键是想好swap 的function怎么写我的做法是输入输出两支点pre& end,中间的两个node swappublic class Solution { public ListNode swapPairs(ListNode head) { if(head==null ||... 阅读全文
posted @ 2015-04-07 05:02 世界到处都是小星星 阅读(143) 评论(0) 推荐(0) 编辑
摘要:也很简单,关键是掌握mergeSort见ref http://www.cnblogs.com/springfor/p/3869217.html, 摘抄这里来复习一下Merge Sort(对于数组操作),参考Wikipedia:归并操作(merge),也叫归并算法,指的是将两个已经排序的序列合并成一个... 阅读全文
posted @ 2015-04-07 04:23 世界到处都是小星星 阅读(248) 评论(0) 推荐(0) 编辑
摘要:很简单public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode h = new ListNode(-1); ListNode l3 = h; ... 阅读全文
posted @ 2015-04-07 03:43 世界到处都是小星星 阅读(99) 评论(0) 推荐(0) 编辑
摘要:很简单的一道题,隐含条件要问清楚, n> len的时候就删除首个public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { if(head==null) return null;... 阅读全文
posted @ 2015-04-06 13:03 世界到处都是小星星 阅读(102) 评论(0) 推荐(0) 编辑
摘要:public class Solution { // http://www.cnblogs.com/springfor/p/3864493.html public ListNode addTwoNumbers(ListNode l1, ListNode l2) { List... 阅读全文
posted @ 2015-04-06 12:18 世界到处都是小星星 阅读(117) 评论(0) 推荐(0) 编辑
摘要:public class Solution { public ArrayList> fourSum(int[] num, int target) { // the same as 3sum ArrayList> res = new ArrayList>(); ... 阅读全文
posted @ 2015-04-06 11:54 世界到处都是小星星 阅读(150) 评论(0) 推荐(0) 编辑
摘要:public int threeSumClosest(int[] num, int target) { //int d = 0; if(num==null || num.length0) low++; if(M... 阅读全文
posted @ 2015-04-04 07:55 世界到处都是小星星 阅读(105) 评论(0) 推荐(0) 编辑
摘要:I 非排好序,最快O(n), 用hashmap解决public class Solution { public int[] twoSum(int[] numbers, int target) { int[] res = new int[2]; HashMap h... 阅读全文
posted @ 2015-04-04 06:45 世界到处都是小星星 阅读(129) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2015-04-04 06:43 世界到处都是小星星 阅读(2) 评论(0) 推荐(0) 编辑