L_J_SHOU

上一页 1 ··· 3 4 5 6 7 8 9 10 下一页

2014年2月16日

LeetCode----Sort List

摘要: Sort a linked list inO(nlogn) time using constant space complexity.采用 归并排序。/** * Definition for singly-linked list. * struct ListNode { * int val;... 阅读全文

posted @ 2014-02-16 17:10 L_J_SHOU 阅读(114) 评论(0) 推荐(0)
LeetCode----Median of Two Sorted Arrays

摘要: Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文

posted @ 2014-02-16 15:00 L_J_SHOU 阅读(130) 评论(0) 推荐(0)
LeetCode----Longest Substring Without Repeating Characters

摘要: Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.For example, the l... 阅读全文

posted @ 2014-02-16 13:14 L_J_SHOU 阅读(130) 评论(0) 推荐(0)

2014年2月15日

微软面试100题---将 二叉搜索树 转化成 有序的双向链表

摘要: Description:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。二叉搜索树和双向链表的定义与实现参考: http://blog.csdn.net/shoulinjun/article/details/18449445 http://blog.csdn.net/shoulinjun... 阅读全文

posted @ 2014-02-15 22:52 L_J_SHOU 阅读(155) 评论(0) 推荐(0)
LeetCode----Longest Consecutive Sequence

摘要: Description:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2]... 阅读全文

posted @ 2014-02-15 20:10 L_J_SHOU 阅读(132) 评论(0) 推荐(0)

2014年2月14日

算法----序列和的 top N

摘要: Description:两个长度为 n 的数组 A 和 B, 各从中选出一个元素相加 A[i] + B[j], 求 top n 小的那些和。思路 1:这样的和总共有 n^2 个, 排序,然后取前 n 个。 时间复杂度 O(n^2 lgn), 空间复杂度 O(n^2) 思路 2:用 最大堆。 1. ... 阅读全文

posted @ 2014-02-14 13:08 L_J_SHOU 阅读(354) 评论(0) 推荐(0)

2014年2月13日

LeetCode----Max Points On a Line

摘要: Max Points on a LineTotal Accepted: 4246 Total Submissions: 42602 Given n points on a 2D plane, find the maximum number of points that lie on the same... 阅读全文

posted @ 2014-02-13 10:04 L_J_SHOU 阅读(127) 评论(0) 推荐(0)

2014年2月12日

LeetCode----Sqrt(x)

摘要: Implement int sqrt(int x).Compute and return the square root of x.思路: 其实就是求解 非线性方程 x^2 = A. (A为开方的数)一般形式是 求解 f (x) = 0解法1: 牛顿切线法这是牛顿在 1736年提出的方法,其实思想非... 阅读全文

posted @ 2014-02-12 21:59 L_J_SHOU 阅读(135) 评论(0) 推荐(0)
LeetCode----First Missing Positive

摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文

posted @ 2014-02-12 21:33 L_J_SHOU 阅读(111) 评论(0) 推荐(0)
数据结构《13》----二叉树 Morris 前序遍历

摘要: 三种二叉树的后序遍历的方法: 1. 递归 O(n) 时间复杂度, O(n) 空间复杂度 2. 迭代(用栈) O(n) 时间复杂度, O(n) 空间复杂度 3. Morris 后序遍历 O(n) 时间复杂度, O(1)空间复杂度关于 Morris 中序遍历见http://blog.... 阅读全文

posted @ 2014-02-12 14:02 L_J_SHOU 阅读(206) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页