摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution... 阅读全文
posted @ 2016-01-06 15:54 西小贝 阅读(139) 评论(0) 推荐(0)
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con... 阅读全文
posted @ 2016-01-06 15:52 西小贝 阅读(146) 评论(0) 推荐(0)
摘要: Implementint sqrt(int x).Compute and return the square root ofx. 1 class Solution {//二分 2 public: 3 int mySqrt(int x) { 4 if(x<=1) 5 ... 阅读全文
posted @ 2016-01-06 15:50 西小贝 阅读(149) 评论(0) 推荐(0)
摘要: Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo... 阅读全文
posted @ 2016-01-06 15:48 西小贝 阅读(118) 评论(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 @ 2016-01-06 15:46 西小贝 阅读(158) 评论(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 @ 2016-01-06 15:46 西小贝 阅读(146) 评论(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. 1 /*... 阅读全文
posted @ 2016-01-06 15:44 西小贝 阅读(157) 评论(0) 推荐(0)
摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie... 阅读全文
posted @ 2016-01-06 15:43 西小贝 阅读(150) 评论(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 @ 2016-01-06 15:42 西小贝 阅读(128) 评论(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 @ 2016-01-06 15:41 西小贝 阅读(116) 评论(0) 推荐(0)