自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(107)
  • 资源 (1)
  • 收藏
  • 关注

转载 系统内存分配

http://www.cnblogs.com/dartagnan/archive/2011/09/11/2173520.htmlhttp://www.inf.udec.cl/~leo/teoX.pdf

2014-09-22 08:07:01 340

转载 选择爱人的数学方法(经典秘书问题)

http://www.cnblogs.com/TenosDoIt/p/3747946.html

2014-09-03 10:10:37 451

原创 [LeetCode] - Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2014-08-13 11:35:25 344

原创 [LeetCode] - Surrounded Regions

Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O X

2014-08-13 09:02:29 322

原创 [LeetCode] - Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3

2014-08-13 08:44:31 310

原创 [LeetCode] - Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to 

2014-08-11 10:51:30 351

转载 浅谈构造函数与析构函数的调用顺序

构造函数    先看看构造函数的调用顺序规则,只要我们在平时编程的时候遵守这种约定,任何关于构造函数的调用问题都能解决;构造函数的调用顺序总是如下:1.基类构造函数。如果有多个基类,则构造函数的调用顺序是某类在类派生表中出现的顺序,而不是它们在成员初始化表中的顺序。2.成员类对象构造函数。如果有多个成员类对象则构造函数的调用顺序是对象在类中被声明的顺序,而不是它们出现在成员初始化表中的

2014-05-01 08:59:12 463 1

转载 两个subarrray的题目

两个subarrray的题目,

2014-04-09 05:44:24 348

原创 [Leetcode] - Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN

2014-03-10 04:09:41 426

原创 [Leetcode] - Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.这道题第一次见到是在Cracking上面。第一次做的时候感觉自己的想法好复杂啊,然后看答案之后才豁然开朗。哎,还是菜。大概的思路是这样的。对于一条直线而言,在解析几何中有若干种表示方法,我记

2014-03-08 10:23:48 535

原创 [Leetcode] - Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2014-03-07 07:41:05 532

原创 [Leetcode] - Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did

2014-03-06 12:36:39 440

转载 最长递增子序列 O(NlogN)算法

今天学习了求最长递增子序列这个题的O(NlogN)的解法。记录一下大概的思路,要不然过一段时间又该忘了。基本思路就是维护一个数组,假设为DP。DP[i]所记录的是,在原始数组的所有长度为i+1的单调递增子序列中,结尾处元素的最小值。同时还需要一个变量len,用来记录当前所遇到的所有元素能组成的递增子序列的最大长度。分析后可以发现,DP这个数组一定是有序的,所以每次对它的更新,可以用二分法来实现

2014-03-06 07:35:27 1280

转载 Morris Traversal

http://blog.csdn.net/ithomer/article/category/694817

2014-02-22 09:14:31 405

原创 Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Analysis: /** * Definition for singly-linked list. * public class ListNode { *

2014-02-12 09:09:42 380

原创 Binary Tree Maximum Path Sum

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 3Return 6.

2014-02-11 09:00:48 532

原创 Anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Analysis: Using a hash table groups all anagrams together. We can sort each strin

2014-02-11 02:54:07 348

原创 [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 of the list.Version 1: Time complexity O

2014-02-11 02:41:03 366

原创 [LeetCode] - Recover Binary Search Tree

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 devis

2014-02-10 14:59:01 382

原创 Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a

2014-02-10 11:07:14 348

原创 [LeetCode] - Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.Analysis: Binary Search. public class Solution { public int sqrt(int x) { if(x<=0) return 0; if(x==1) retu

2014-02-10 10:38:28 305

原创 Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m

2014-02-10 03:49:07 367

原创 [LeetCode] - Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "

2014-02-10 03:41:26 395

原创 [LeetCode] - Word Break

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 = ["leet"

2014-02-10 03:28:54 399

原创 Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically

2014-02-10 03:11:56 349

原创 Pow(x, n)

Implement pow(x, n).Analysis: public class Solution { public double power(double x, int n) { if(n==0) return 1; double y = power(x, n/2); if(n%2==0) return y*y;

2014-02-10 02:59:28 346

原创 Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order

2014-02-09 12:25:49 369

原创 Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary

2014-02-09 09:32:49 342

原创 Divide Two Integers

Version 1: Not that efficient for large numbers, so it cannot pass large test cases. public class Solution { public int flip(int a) { int neg = 0; int acc = (a>0) ? -1 : 1;

2014-02-09 02:17:15 375

原创 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->3->3->4->4->5, return 1->2->5.Given 1->1-

2014-02-09 01:29:16 417

原创 Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E

2014-02-09 01:02:59 351

原创 Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Analysis: 1. Sorting each intervals in ascendi

2014-02-09 00:09:56 310

原创 Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [

2014-02-08 15:17:49 355

原创 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I

2014-02-07 04:51:25 333

原创 Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]

2014-02-06 09:20:33 317

原创 [LeetCode] - Validate Binary Search Tree

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 node's key.Th

2014-02-05 05:24:25 355

原创 Flatten Binary Tree to Linked List

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: 1

2014-02-05 02:59:44 351

原创 Jump Game II

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.Your goal i

2014-02-04 14:33:56 343

原创 Jump Game

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.Determine i

2014-02-04 13:52:04 329

原创 Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina

2014-01-31 03:27:10 390

Objective-C_中文_第二版

非常好的Objective C入门资料,短小精悍,有助于了解语言最基本的特点。

2013-03-14

空空如也

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

TA关注的人

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