自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

鱼思故渊的专栏

不积跬步,无以至千里;不积小流,无以成江海

  • 博客(1069)
  • 资源 (3)
  • 收藏
  • 关注

原创 Intersection of Two Linked Lists--LeetCode

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘

2015-04-11 21:11:19 486

原创 Largest Number--LeetCode

Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is9534330.Note: The result may be very

2015-04-11 20:34:48 702

原创 Maximum Gap --LeetCode

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements.Y

2015-04-11 20:21:45 759

原创 Find Peak Element--LeetCode

A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in that

2015-04-11 19:52:13 473

原创 Min Stack--LeetCode

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-04-11 19:40:17 756

原创 Find Minimum in Rotated Sorted Array II--LeetCode

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unkno

2015-04-11 19:23:43 532

原创 Find Minimum in Rotated Sorted Array--LeetCode

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the arra

2015-04-11 19:20:53 502

原创 Palindrome Partitioning II--LeetCode

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab"

2015-04-11 16:18:47 575

原创 Palindrome Partitioning--LeetCode

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return

2015-04-11 16:07:43 819

原创 word break II--LeetCode

public ArrayList wordBreak(String s, Set dict) { ArrayList res = new ArrayList(); if(s==null || s.length()==0) return res; helper(s,dict,0,"",res);

2015-04-11 11:35:18 1000

原创 Word Break--LeetCode

题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict

2015-04-11 11:29:01 903

原创 Populating Next Right Pointers in Each Node II--LeetCode

题目:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only us

2015-04-11 10:19:43 516

原创 Populating Next Right Pointers in Each Node--LeetCode

题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right n

2015-04-10 22:26:42 571

原创 Binary Tree Maximum Path Sum--LeetCode

题目:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3思路:刚开始思路

2015-04-09 11:44:23 816

原创 Sum Root to Leaf Numbers--LeetCode

题目:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Fi

2015-04-09 11:34:00 702

原创 Pascal's Triangle II--LeetCode

题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?

2015-04-09 10:10:23 732

原创 Pascal's Triangle--LeetCode

题目:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路:第n层有n个数,而且第n

2015-04-09 09:48:23 663

原创 Flatten Binary Tree to Linked List--LeetCode

题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:

2015-04-09 09:37:25 656

原创 Symmetric Tree--LeetCode

题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But

2015-04-08 23:08:06 479

原创 Recover Binary Search Tree--LeetCode

题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a con

2015-04-08 22:50:46 534

原创 Same Tree--LeetCode

题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思

2015-04-08 17:36:41 464

原创 Validate Binary Search Tree--LeetCode

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the no

2015-04-08 17:30:30 486

原创 Unique Binary Search Trees II--LeetCode

题目:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1

2015-04-08 16:56:33 564

原创 Unique Binary Search Trees--LeetCode

题目:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2

2015-04-08 16:35:46 612

原创 Anagrams--LeetCode

题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路:判断两个字符串是否为anagram的方法可以有:1)将每个字符串的所有字符按字典序排列,比较是否相同。2)用Has

2015-04-08 14:46:37 656

原创 Pow(x,n)--LeetCode

题目:实现pow()思路:使用二分法,不过这道题用递归来解比较容易理解,把x的n次方划分成两个x的n/2次方相乘,然后递归求解子问题,结束条件是n为0返回1。因为是对n进行二分,算法复杂度和上面方法一样,也是O(logn)。代码如下:#include #include using namespace std;double pow(double x, int n) { if

2015-04-08 10:47:02 588

原创 Sqrt(x) --LeetCode

题目:实现sqrt(x)思路:一般都是使用二分法,但是也可以使用牛顿法来实现更高的速度#include #include #include using namespace std;int Sqrt(int num){ if(num == 1 && num == 0) return num; int low =1,high = num/2+1; int mid;

2015-04-08 10:26:22 684

原创 Single Number II--LeetCode

题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wi

2015-04-07 23:24:53 449

原创 Spiral Matrix II--LeetCode

题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9

2015-04-07 21:56:41 597

原创 Spiral Matrix--LeetCode

题目:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9

2015-04-07 21:33:18 438

原创 Jump Game II--LeetCode

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Yo

2015-04-07 20:37:27 567

原创 Jump Game--LeetCode

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.De

2015-04-07 19:32:43 566

原创 Rotate Image --LeetCode

题目:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:使用最基本的方法,递归,但是有空间复杂度#include #inc

2015-04-07 19:00:51 537

原创 Search in Rotated Sorted Array II-LeetCode

过正是因为这个条件的出现,出现了比较复杂的case,甚至影响到了算法的时间复杂度。原来我们是依靠中间和边缘元素的大小关系,来判断哪一半是不受rotate影响,仍然有序的。而现在因为重复的出现,如果我们遇到中间和边缘相等的情况,我们就丢失了哪边有序的信息,因为哪边都有可能是有序的结果。假设原数组是{1,2,3,3,3,3,3},那么旋转之后有可能是{3,3,3,3,3,1,2},或者{3,1,2,3

2015-04-07 16:29:17 607

原创 Search in Rotated Sorted Array--LeetCode

题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the ar

2015-04-07 16:25:26 569

原创 Generate Parentheses--LeetCode

题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(()

2015-04-07 11:10:26 578

原创 Container With Most Water--LeetCode

题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,

2015-04-06 16:53:24 675

原创 String to Integer (atoi)--LeetCode

这种题的考察重点并不在于问题本身,而是要注意corner case的处理,整数一般有两点,一个是正负符号问题,另一个是整数越界问题。思路比较简单,就是先去掉多余的空格字符,然后读符号(注意正负号都有可能,也有可能没有符号),接下来按顺序读数字,结束条件有三种情况:(1)异常字符出现(按照C语言的标准是把异常字符起的后面全部截去,保留前面的部分作为结果);(2)数字越界(返回最接近的整数);(3)字

2015-04-06 16:02:07 676

原创 Add Two Numbers--LeetCode

题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it

2015-04-06 15:31:18 795

原创 Add Binary--LeetCode

题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:字符串的叠加,注意进位string AddBinary(string& first,string& second){ strin

2015-04-05 15:14:15 587

nginx源码分析--带注释

nginx源码分析,分析过程中将重要的部分进行了注释,以便理解

2014-11-26

libevent-1.4.12-stable-注释版

注释了libevent中很关键的部分,很重要的接口函数。

2014-03-07

3G模块驱动运用开发总结

在特定ARM开发板上使用linux 进行3G拨号的连接

2012-11-16

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除