自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(159)
  • 收藏
  • 关注

转载 【Leetcode】Intersection of Two Linked Lists

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 ↘

2014-11-28 01:51:28 430

转载 【Leetcode】Min Stack

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

2014-11-12 10:53:28 199

转载 【Leetcode】Find Minimum in Rotated Sorted Array II

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 unk

2014-11-10 04:56:22 186

转载 面试准备

入门:获取比较全面的CS知识最快的方法,www.programmerinterview.com建立起了CS思维过程Structure and Interpretation of computer programming:http://www.youtube.com/playlist?list=PL3E89002AA9B9879E学语言:codeacade

2014-10-20 13:00:18 220

转载 【Leetcode】Find Minimum in Rotated Sorted Array

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

2014-10-16 23:23:20 445 1

转载 【Leetcode】3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c

2014-10-07 10:08:05 144

转载 【Leetcode】Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as 

2014-10-07 04:08:40 163

转载 【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.Java:

2014-10-06 01:04:06 153

转载 【Leetcode】Valid Number

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo

2014-10-04 14:56:09 168

原创 【Leetcode】Reverse Words in a String

Java:http://blog.csdn.net/linhuanmars/article/details/20982463public class Solution { public String reverseWords(String s) { if(s==null) return null; s=s.trim(); if(s.leng

2014-10-04 13:18:37 189

转载 【Leetcode】LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-10-04 07:17:41 150

转载 【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-10-04 03:52:41 168

转载 【Leetcode】String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2014-10-04 01:40:57 132

原创 【Leetcode】Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu

2014-10-03 10:35:36 178

转载 【Leetcode】Divide Two Integers

Divide two integers without using multiplication, division and mod operator.Java:http://blog.csdn.net/linhuanmars/article/details/20024907

2014-10-03 10:15:34 201

原创 【Leetcode】Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2014-10-03 08:07:33 178

转载 【Leetcode】Maximum Product Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges

2014-10-03 07:23:36 417

转载 【Leetcode】Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Java:http://blog.csdn.net/l

2014-10-03 06:23:41 168

转载 【Leetcode】Substring with Concatenation of All Words

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an

2014-10-03 05:35:44 179

转载 【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-10-02 11:23:23 171

转载 【Leetcode】Word Ladder II - hardest

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exi

2014-10-02 06:12:13 139

转载 【Leetcode】Word Ladder I

Java:http://blog.csdn.net/linhuanmars/article/details/23029973图 广度优先public class Solution { public int ladderLength(String start, String end, HashSet dict) { if(st

2014-10-02 04:56:45 128

转载 【Leetcode】Two Sum (2 Sum)

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2014-10-01 10:28:44 127

转载 【Leetcode】Candy

There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on

2014-10-01 07:27:58 100

转载 【Leetcode】Interleaving String - 动态规划二维转一维

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret

2014-10-01 06:11:31 224

转载 【Leeetcode】Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",

2014-10-01 04:34:24 167

转载 【Leetcode】Evaluate Reverse Polish Notation

"以上代码中有一个没有周全的地方是没有对逆波兰式错误的情况进行出错处理,其实也不难,就是每次pop操作检查栈空情况,如果栈空,则说明出错。还有就是最后检查一下栈的size,如果不是1也说明运算数多了,返回错误。有兴趣的朋友可以自己补充一下哈。"Java:

2014-10-01 00:32:21 110

转载 【Leetcode】Word Search

Java:http://blog.csdn.net/linhuanmars/article/details/24336987深度优先 public class Solution { public boolean exist(char[][] board, String word) { if(word==null||word.length(

2014-09-30 13:04:05 127

转载 【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-09-30 11:30:44 109

转载 【Leetcode】Regular Expression Matching - hard

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st

2014-09-30 07:25:28 155

转载 【Leetcode】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-09-30 03:49:19 134

转载 【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 t

2014-09-29 12:20:13 128

转载 【Leetcode】Sort List

Sort a linked list in O(n log n) time using constant space complexity.Java:

2014-09-29 09:32:01 151

转载 【Leetcode】Multiply Strings

Java:public class Solution { public String multiply(String num1, String num2) { // reverse String n1= new StringBuilder(num1).reverse().toString(); String n2= new

2014-09-29 07:20:12 150

转载 【Leetcode】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-09-29 04:39:30 121

转载 【Leetcode】Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.Java:pub

2014-09-27 21:50:55 129

转载 【Leetcode】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-09-27 13:20:07 134

转载 【Leetcode】Merge Intervals

Java:1. http://blog.csdn.net/linhuanmars/article/details/218576172. 备用:/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start

2014-09-27 12:32:55 152

转载 【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-09-26 13:06:38 156

转载 【Leetcode】Word Break I - 动态规划

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-09-26 12:26:51 130

空空如也

空空如也

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

TA关注的人

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