题意:二维坐标系里有 n 个点 (i, ai), ai >= 0,从 (i, ai)到(i, 0)划竖线,共有 n 条竖线。
找出两条竖线,使得它们构成的矩形的面积最大,矩形的高取决于最短的竖线。
思路:贪心
从首尾两个下标head 和trail 处开始扫描,用一个变量 maxArea 保持当前最大的矩形面积。
如果head 指向的竖线短于 trail 的,则右移 head
否则左移 trail
计算面积,更新 maxArea
复杂度:时间O(n),空间O(1)
int maxArea(vector<in...
分类:
其他好文 时间:
2014-08-30 16:27:49
阅读次数:
223
首先介绍DOM里常见的三种节点类型(总共有12种,如docment):元素节点,属性节点以及文本节点,例如head,其中h2是元素节点,class是属性节点,head是文本节点,在这里你可以说 h2这个元素节点包含一个属性节点和一个文本节点。其实几乎所有HTML的标签都是元素节点,而id, ti.....
分类:
其他好文 时间:
2014-08-30 15:03:59
阅读次数:
184
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the...
分类:
其他好文 时间:
2014-08-30 08:49:59
阅读次数:
210
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-08-30 01:11:08
阅读次数:
286
The?JVM doesn’t support TCO natively, so tail recursive methods will need to rely on the?Scala compiler performing the optimization.----------"Scala in Depth" 3.5.2 Jvm本身是不支持尾递归优化得,...
分类:
其他好文 时间:
2014-08-29 22:47:58
阅读次数:
368
19.$("div#intro .head") 选择器选取哪些元素? 您的回答:id="intro" 的首个 div 元素中的 class="head" 的所有元素 20.jQuery 是 W3C 标准吗? 您的回答:Yes 正确答案:No 2.jQuery 使用 CSS 选择器来选取元素...
分类:
Web程序 时间:
2014-08-29 18:36:58
阅读次数:
260
# uname -a # 查看内核/操作系统/CPU信息# head -n 1 /etc/issue # 查看操作系统版本# cat /proc/cpuinfo # 查看CPU信息# hostname # 查看计算机名# lspci -tv # 列出所有PCI设备# lsusb -tv # 列出所有...
分类:
系统相关 时间:
2014-08-29 18:14:08
阅读次数:
271
题目:
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only cons...
分类:
其他好文 时间:
2014-08-29 13:13:37
阅读次数:
169
每个表格输入都有一个form对象可以作为参数,如:...function showIt(theForm){ alert(theForm["zipcode"].value);} this.form表示该表格的form对象作为参数被传进函数,在showIt()函数中用"zipcode"来引用这个对...
分类:
编程语言 时间:
2014-08-29 13:01:57
阅读次数:
212
linux下获取占用CPU资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head linux下获取占用内存资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps au...
分类:
其他好文 时间:
2014-08-29 11:18:18
阅读次数:
197