2013年10月25日

Search for a Range

摘要: Given 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 target value 8,return[3, 4].思路二分查找的变形 阅读全文

posted @ 2013-10-25 19:13 waruzhi 阅读(246) 评论(0) 推荐(0) 编辑

Set Matrix Zeroes

摘要: 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 using O(mn) space is probably a bad idea.A simple improvement uses O(m+n) space, but still not the best solution.Could you devise a constant space so 阅读全文

posted @ 2013-10-25 18:44 waruzhi 阅读(237) 评论(0) 推荐(0) 编辑

导航