摘要: Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo... 阅读全文
posted @ 2015-06-25 15:20 丶Blank 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2015-06-25 13:41 丶Blank 阅读(156) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-06-25 13:39 丶Blank 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Implementint sqrt(int x).Compute and return the square root ofx.题目大意:实现求一个int的根。解题思路:二分。public class Solution { public int mySqrt(int x) { i... 阅读全文
posted @ 2015-06-25 13:36 丶Blank 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"题目大意:给一个String,表示一个文件的绝对... 阅读全文
posted @ 2015-06-25 13:34 丶Blank 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except... 阅读全文
posted @ 2015-06-25 12:33 丶Blank 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-06-25 11:37 丶Blank 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Description:Count the number of prime numbers less than a non-negative number,n.题目大意:给一个int,返回小于它的质数的数量。解题思路:打表。public class Solution { public ... 阅读全文
posted @ 2015-06-25 11:34 丶Blank 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-06-25 11:32 丶Blank 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-06-25 11:29 丶Blank 阅读(125) 评论(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 @ 2015-06-25 11:19 丶Blank 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
posted @ 2015-06-25 11:11 丶Blank 阅读(150) 评论(0) 推荐(0) 编辑