摘要:
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.思考:在上一题的基础上思考几个边界问题。[1,3] 3 [1,3] 3[3,3] 1 [3,1] 3[1,3,1,1,1] 3[1,1,1,3,1] 1class Solution {pub 阅读全文
摘要:
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.思考:跟上一题一样,维护左右边界。参考:http://discuss.leetcode.com/questions/260/maximal-rectangle#class Solution {public: int maximalRectangle(vector > &matrix) { if (matrix.empty()) { . 阅读全文