05 2014 档案

摘要: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 "adjace... 阅读全文
posted @ 2014-05-26 16:34 一弦一仙 阅读(346) 评论(0) 推荐(0) 编辑
摘要: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 concatenati... 阅读全文
posted @ 2014-05-26 16:33 一弦一仙 阅读(200) 评论(0) 推荐(0) 编辑
摘要: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 maximu... 阅读全文
posted @ 2014-05-26 09:23 一弦一仙 阅读(155) 评论(0) 推荐(0) 编辑
摘要:Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文
posted @ 2014-05-22 21:41 一弦一仙 阅读(188) 评论(0) 推荐(0) 编辑
摘要:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2014-05-22 21:30 一弦一仙 阅读(249) 评论(0) 推荐(0) 编辑
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number ... 阅读全文
posted @ 2014-05-22 21:28 一弦一仙 阅读(234) 评论(0) 推荐(0) 编辑
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-05-21 21:59 一弦一仙 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2014-05-21 21:18 一弦一仙 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2014-05-21 09:43 一弦一仙 阅读(125) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2014-05-20 22:36 一弦一仙 阅读(128) 评论(0) 推荐(0) 编辑
摘要:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2014-05-20 14:24 一弦一仙 阅读(172) 评论(0) 推荐(0) 编辑
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2014-05-19 22:55 一弦一仙 阅读(220) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2014-05-19 11:45 一弦一仙 阅读(138) 评论(0) 推荐(0) 编辑
摘要:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i... 阅读全文
posted @ 2014-05-18 23:06 一弦一仙 阅读(149) 评论(0) 推荐(0) 编辑
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,... 阅读全文
posted @ 2014-05-18 21:20 一弦一仙 阅读(189) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2014-05-18 20:24 一弦一仙 阅读(103) 评论(0) 推荐(0) 编辑
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".public class Solution { public String addBin... 阅读全文
posted @ 2014-05-18 19:53 一弦一仙 阅读(154) 评论(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.start... 阅读全文
posted @ 2014-05-18 12:02 一弦一仙 阅读(131) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo 阅读全文
posted @ 2014-05-17 17:10 一弦一仙 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2014-05-17 15:39 一弦一仙 阅读(182) 评论(0) 推荐(0) 编辑
摘要:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2014-05-17 14:01 一弦一仙 阅读(157) 评论(0) 推荐(0) 编辑
摘要: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 fol... 阅读全文
posted @ 2014-05-17 13:56 一弦一仙 阅读(159) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2014-05-17 13:54 一弦一仙 阅读(178) 评论(0) 推荐(0) 编辑
摘要: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 maximu... 阅读全文
posted @ 2014-05-16 15:54 一弦一仙 阅读(156) 评论(0) 推荐(0) 编辑
摘要: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 maximu... 阅读全文
posted @ 2014-05-16 14:40 一弦一仙 阅读(139) 评论(0) 推荐(0) 编辑
摘要:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: For example, Given:start 阅读全文
posted @ 2014-05-15 22:22 一弦一仙 阅读(249) 评论(0) 推荐(0) 编辑
摘要:一、安装JDK和Tomcat1,安装JDK:直接运行jdk-7-windows-i586.exe可执行程序,默认安装即可。备注:路径可以其他盘符,不建议路径包含中文名及特殊符号。2、安装Tomcat:直接解压缩下载文件“apache-tomcat-7.0.33-windows-x86.zip”到C盘... 阅读全文
posted @ 2014-05-15 09:29 一弦一仙 阅读(554) 评论(0) 推荐(0) 编辑
摘要:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: For example, Give 阅读全文
posted @ 2014-05-14 20:21 一弦一仙 阅读(148) 评论(0) 推荐(0) 编辑
摘要: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].public class S... 阅读全文
posted @ 2014-05-13 16:45 一弦一仙 阅读(176) 评论(0) 推荐(0) 编辑
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2014-05-13 14:34 一弦一仙 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文
posted @ 2014-05-13 11:24 一弦一仙 阅读(125) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-05-12 23:33 一弦一仙 阅读(123) 评论(0) 推荐(0) 编辑
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.public class S... 阅读全文
posted @ 2014-05-12 00:26 一弦一仙 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.public class So... 阅读全文
posted @ 2014-05-12 00:06 一弦一仙 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2014-05-11 23:27 一弦一仙 阅读(191) 评论(0) 推荐(0) 编辑
摘要:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文
posted @ 2014-05-11 20:34 一弦一仙 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文
posted @ 2014-05-11 20:23 一弦一仙 阅读(142) 评论(0) 推荐(0) 编辑
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:先将矩阵转置,然后将第一列与最后... 阅读全文
posted @ 2014-05-11 18:57 一弦一仙 阅读(127) 评论(0) 推荐(0) 编辑
摘要:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2014-05-11 17:10 一弦一仙 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2014-05-11 16:04 一弦一仙 阅读(124) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-05-11 15:50 一弦一仙 阅读(129) 评论(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 @ 2014-05-11 15:05 一弦一仙 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2014-05-11 14:41 一弦一仙 阅读(140) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list using insertion sort.//用到O(N)的额外空间public class Solution { public ListNode insertionSortList(ListNode head) { if(head==nul... 阅读全文
posted @ 2014-05-11 12:58 一弦一仙 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.1. 将LinkedList的值保存到一个数组中,转化成Convert Sorte... 阅读全文
posted @ 2014-05-10 22:18 一弦一仙 阅读(155) 评论(0) 推荐(0) 编辑
摘要: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 n... 阅读全文
posted @ 2014-05-10 20:35 一弦一仙 阅读(134) 评论(0) 推荐(0) 编辑
摘要:原文链接http://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/http://blog.csdn.net/linhuanmars/article/details/20588511这道题是二分查找Search Insert P... 阅读全文
posted @ 2014-05-10 19:53 一弦一仙 阅读(151) 评论(0) 推荐(0) 编辑
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2014-05-10 19:13 一弦一仙 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A s... 阅读全文
posted @ 2014-05-10 18:49 一弦一仙 阅读(206) 评论(0) 推荐(0) 编辑
摘要:Implementint sqrt(int x).Compute and return the square root ofx.原文地址:http://kb.cnblogs.com/page/189867/好吧,我承认我标题党了,不过既然你来了,就认真看下去吧,保证你有收获。 我们平时经常会有一些... 阅读全文
posted @ 2014-05-10 16:10 一弦一仙 阅读(214) 评论(0) 推荐(0) 编辑
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.public class Solution { public String int... 阅读全文
posted @ 2014-05-10 15:51 一弦一仙 阅读(171) 评论(0) 推荐(0) 编辑
摘要:贪心算法1.性质贪心算法通过一系列的选择来得到问题的解。它所做的每一个选择都是当前状态下局部的最好选择,即贪心选择。贪心选择的一般特征:贪心选择性质和最优子结构性质。在动态规划算法中,每步所作的选择往往依赖于相关子问题的解。因而只有在解出相关子问题后,才能作出选择。而在贪心算法中,仅在当前状态下作出... 阅读全文
posted @ 2014-05-10 15:15 一弦一仙 阅读(484) 评论(0) 推荐(0) 编辑
摘要:转载:http://blog.csdn.net/fightforyourdream/article/details/14503469题目:最佳时间买入卖出股票:你有一个数组保存了股票在第i天的价钱,现在你最多进行两次买卖,但同一时间你手上只能保持一个股票,如何赚的最多思路:知道要用DP做,但是一开始... 阅读全文
posted @ 2014-05-09 15:23 一弦一仙 阅读(185) 评论(0) 推荐(0) 编辑
摘要:http://blog.unieagle.net/category/develop/%E7%AE%97%E6%B3%95/ 阅读全文
posted @ 2014-05-09 11:17 一弦一仙 阅读(137) 评论(0) 推荐(0) 编辑
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2014-05-09 11:14 一弦一仙 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
posted @ 2014-05-09 10:22 一弦一仙 阅读(144) 评论(0) 推荐(0) 编辑
摘要:java ReplaceAll 的两个参数都必须是正则表达式。在正则表达式中 \ (一个斜线)是用 \\ 来表示(即:用两个斜线表示一个斜线) 而在Java语言中 \ (一个斜线)是用 \\ 来表示。(即:也用两个斜线表示一个斜线) 所以正则表达式为两个斜线("\\")的写法,在Java语言中要用4... 阅读全文
posted @ 2014-05-09 09:23 一弦一仙 阅读(3813) 评论(0) 推荐(0) 编辑
摘要: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 / \ ... 阅读全文
posted @ 2014-05-08 20:34 一弦一仙 阅读(158) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4... 阅读全文
posted @ 2014-05-08 20:14 一弦一仙 阅读(147) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or ... 阅读全文
posted @ 2014-05-08 20:08 一弦一仙 阅读(178) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/maximum-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest s... 阅读全文
posted @ 2014-05-08 19:26 一弦一仙 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2014-05-07 23:15 一弦一仙 阅读(120) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/balanced-binary-tree/http://blog.csdn.net/fightforyourdream/article/details/18693131Given a binary tree, determine if ... 阅读全文
posted @ 2014-05-07 22:55 一弦一仙 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN... 阅读全文
posted @ 2014-05-07 22:08 一弦一仙 阅读(155) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2014-05-07 21:56 一弦一仙 阅读(146) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/Given a binary tree struct TreeLinkNode { TreeLinkNode *left; ... 阅读全文
posted @ 2014-05-07 21:25 一弦一仙 阅读(159) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2014-05-06 22:20 一弦一仙 阅读(113) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?F... 阅读全文
posted @ 2014-05-06 22:17 一弦一仙 阅读(89) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Inorder TraversalTotal Accepted:16406Total Submissions:47212My SubmissionsGiven a binary tree, return theinordertraversal of its nodes' va... 阅读全文
posted @ 2014-05-06 21:24 一弦一仙 阅读(88) 评论(0) 推荐(0) 编辑
摘要:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fir... 阅读全文
posted @ 2014-05-06 21:12 一弦一仙 阅读(106) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/reverse-integer/public class Solution { public int reverse(int x) { String strX = Integer.toString(x); ... 阅读全文
posted @ 2014-05-06 20:29 一弦一仙 阅读(132) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/same-tree/public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { Stack pstack = new... 阅读全文
posted @ 2014-05-06 20:17 一弦一仙 阅读(114) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/public class Solution { public int maxDepth(TreeNode root) { if(root!=null){ ... 阅读全文
posted @ 2014-05-06 19:50 一弦一仙 阅读(90) 评论(0) 推荐(0) 编辑
摘要:http://oj.leetcode.com/problems/minimum-path-sum/public class Solution { public int minPathSum(int[][] grid) { int row = grid.length; ... 阅读全文
posted @ 2014-05-06 19:40 一弦一仙 阅读(101) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示