摘要: 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-05-15 23:57 TonyLuis 阅读(154) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any po... 阅读全文
posted @ 2015-05-15 21:50 TonyLuis 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->... 阅读全文
posted @ 2015-05-15 21:21 TonyLuis 阅读(129) 评论(0) 推荐(0) 编辑
摘要: The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence ... 阅读全文
posted @ 2015-05-15 20:43 TonyLuis 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3,You should return the followin... 阅读全文
posted @ 2015-05-15 19:59 TonyLuis 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word ... 阅读全文
posted @ 2015-05-15 19:44 TonyLuis 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initial... 阅读全文
posted @ 2015-05-15 19:23 TonyLuis 阅读(198) 评论(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].解题思路一:用两个指针... 阅读全文
posted @ 2015-05-15 18:06 TonyLuis 阅读(237) 评论(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 @ 2015-05-15 11:05 TonyLuis 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix:[ [ 1,... 阅读全文
posted @ 2015-05-15 10:53 TonyLuis 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,... 阅读全文
posted @ 2015-05-15 10:10 TonyLuis 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.解题思路:和上题一样《JAVA语言程序设计》中exer... 阅读全文
posted @ 2015-05-15 09:47 TonyLuis 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, return all distinct solutions to the n-queens puzzle.Each solution contains a distinct board configuration of the n-queens' placem... 阅读全文
posted @ 2015-05-15 09:43 TonyLuis 阅读(167) 评论(0) 推荐(0) 编辑