摘要:
Minimum Path Sum2013.12.21 23:32Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at any point in time.Solution1: Given a 2-d matrix of size m x n, with all eleme. 阅读全文
posted @ 2013-12-21 23:34
zhuli19901106
阅读(224)
评论(0)
推荐(0)
摘要:
Unique Paths II2013.12.21 03:19Follow 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 is marked as1and0respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as ill 阅读全文
posted @ 2013-12-21 03:28
zhuli19901106
阅读(235)
评论(0)
推荐(0)
摘要:
Unique Paths2013.12.21 02:43A 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 in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram 阅读全文
posted @ 2013-12-21 03:19
zhuli19901106
阅读(212)
评论(0)
推荐(0)
摘要:
Rotate List2013.12.21 02:02Given 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.Solution1: My first solution is clumsy with O(n^2) time complexity (X_X), at least it proves that 阅读全文
posted @ 2013-12-21 02:27
zhuli19901106
阅读(172)
评论(0)
推荐(0)
摘要:
Spiral Matrix II2013.12.21 01:54Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]Solution: Still spiral order traversal of an m X n matrix, please see " 阅读全文
posted @ 2013-12-21 01:59
zhuli19901106
阅读(204)
评论(0)
推荐(0)
摘要:
Length of Last Word2013.12.21 01:48Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note:A word is defined as a character sequence consists of non-space characters only. 阅读全文
posted @ 2013-12-21 01:54
zhuli19901106
阅读(251)
评论(0)
推荐(0)
摘要:
Spiral Matrix2013.12.21 01:37Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should return[1,2,3,6,9,8,7,4,5].Solution: Given an m X n matrix, traverse it in a clockwi. 阅读全文
posted @ 2013-12-21 01:39
zhuli19901106
阅读(247)
评论(0)
推荐(0)


浙公网安备 33010602011771号