上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 51 下一页
2014年2月26日
摘要: Interleaving String2014.2.26 02:48Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", return false.Solution1: This problem can be solved with DFS, bu 阅读全文
posted @ 2014-02-26 03:29 zhuli19901106 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Gas Station2014.2.26 00:34There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited ... 阅读全文
posted @ 2014-02-26 02:09 zhuli19901106 阅读(351) 评论(0) 推荐(0) 编辑
2014年2月25日
摘要: Evaluate Reverse Polish Notation2014.2.25 23:42Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3", "*"] -> (( 阅读全文
posted @ 2014-02-25 23:53 zhuli19901106 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Edit Distance2014.2.25 23:07Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) Insert a characterb) Delete a characterc) Replace a characterSolution1: This i. 阅读全文
posted @ 2014-02-25 23:39 zhuli19901106 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Clone Graph2014.2.25 22:15Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use#as a separator for each node, and,as a separator for node label and each neighbor of the node.As an example, 阅读全文
posted @ 2014-02-25 22:58 zhuli19901106 阅读(270) 评论(0) 推荐(0) 编辑
摘要: Candy2014.2.25 21:34There areNchildren 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 one candy.Children with a higher rating get more candies than their neighbors.What is the mi 阅读全文
posted @ 2014-02-25 22:11 zhuli19901106 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 3Sum Closest2014.2.25 19:02Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. ... 阅读全文
posted @ 2014-02-25 21:16 zhuli19901106 阅读(285) 评论(2) 推荐(0) 编辑
2014年2月13日
摘要: Set Matrix Zeroes2014.2.13 22:15Given 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 straight forward solution using O(mn) space is probably a bad idea.A simple improvement uses O(m+n) space, but still no 阅读全文
posted @ 2014-02-13 22:50 zhuli19901106 阅读(217) 评论(0) 推荐(0) 编辑
摘要: Search for a Range2014.2.13 20:27Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order ofO(logn).If the target is not found in the array, return[-1, -1].For example,Given[5, 7, 7, 8, 8, 10]and targ 阅读全文
posted @ 2014-02-13 20:42 zhuli19901106 阅读(168) 评论(0) 推荐(0) 编辑
摘要: N-Queens II2014.2.13 20:01Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.Solution: This problem is a simplification from the N-Queens. This time we only have record the number of solutions. Time complexity is O(n!). Space .. 阅读全文
posted @ 2014-02-13 20:22 zhuli19901106 阅读(294) 评论(0) 推荐(0) 编辑
上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 51 下一页