Given a 2D binary matrix filled with 0's and 1's,find the largest square containing only 1's and return its area. Input: 1 0 1 0 01 0 1 1 11 1 1 1 11 ...
分类:
其他好文 时间:
2019-09-11 20:11:23
阅读次数:
106
原题链接在这里:https://leetcode.com/problems/largest-sum-of-averages/ 题目: We partition a row of numbers A into at most K adjacent (non-empty) groups, then ou ...
分类:
其他好文 时间:
2019-09-03 13:29:25
阅读次数:
87
/** * 给出n个数字,代表直方图的条高,直方图每一条的宽度为1,请计算直方图中最大矩形的面积 * * 上图是每条宽度为1, 高度 =[2,1,5,6,2,3].的直方图 * * 图中的阴影部分是该直方图中面积最大的矩形,面积为10个单位 * 例如: * 给出的高度 =[2,1,5,6,2,3],... ...
分类:
其他好文 时间:
2019-08-20 11:03:24
阅读次数:
73
【题目链接】 https://loj.ac/problem/10050 【题意】 给出n个数,其中取出两个数来,让其异或值最大。 【题解】 经典的01字典树问题。 首先需要把01字典树建出来。 然后对于每一个串都跑一遍。如果存在当前位 不同的 节点,就往那里跑,否则顺着跑。 一切尽在代码中。 【代码 ...
分类:
其他好文 时间:
2019-08-16 09:15:28
阅读次数:
88
(链接点这儿) 题目: The GCD of two positive integers is the largest integer that divides both the integers without any remainder. The LCM of two positive inte ...
分类:
其他好文 时间:
2019-08-10 20:59:27
阅读次数:
85
就是用快排那种划分,每次确定一个最终元素的位置,如果该位置是要找的数,则返回 ...
分类:
其他好文 时间:
2019-08-08 21:29:48
阅读次数:
106
problem 976. Largest Perimeter Triangle solution: 参考 1. Leetcode_easy_976. Largest Perimeter Triangle; 完 ...
分类:
其他好文 时间:
2019-08-07 19:33:51
阅读次数:
86
221 medium 221. Maximal Square Medium Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its are ...
分类:
其他好文 时间:
2019-08-06 20:01:38
阅读次数:
68
单调栈和队列讲解:传送门 HDU -1506题意: 就是给你一些矩形的高度,让你统计由这些矩形构成的那个矩形面积最大 如上图所示,如果题目给出的全部是递增的,那么就可以用贪心来解决 从左向右依次让每一个矩形的高度当作最后的高度,来从中选取最大值就可以了 但是如果它不是递增的,中间会出现低谷,那么要还 ...
分类:
其他好文 时间:
2019-07-31 18:59:28
阅读次数:
110
刷 July 27 2019 这个题做了好久,面试遇到就跪了,只会暴力解。 而且也讲不明白。简单说就是用stack保证递增: 添加2,下一个是1,不递增了,POP出2然后算结果是乘积是2. 继续添加1 5 6,然后下一个是2,不递增了,POP出6和5算乘积是6和10. 添加2和3,此时STACK里是 ...
分类:
其他好文 时间:
2019-07-28 15:56:11
阅读次数:
76