这道题要求的一个min和一个max,只是这个min所在的位置要在max所在位置的左边。有一种做法是采用蛮力算法,也就是通过从左往右遍历,把每一个元素都当做min,然后再在这个元素的右边找一个最大值,这样得到一个profit,最后求得所有情况中profit的最大值即刻。但是这种做法的时间复杂度是O(n...
分类:
其他好文 时间:
2014-05-01 10:17:20
阅读次数:
287
判断valid,没有更好的方法,只能brute force。 1 class Solution { 2
public: 3 bool isValidSudoku(vector > &board) { 4 5 int n; 6 for (int...
分类:
其他好文 时间:
2014-05-01 08:54:28
阅读次数:
332
一开始听到WPF,觉得很陌生。在百度百科等地方看完简介之后,感觉更深奥,各种不懂啊!在简单做了几个页面之后,发现,原来如此!
So Easy 但又So Magic。
为什么说它简单?因为它简直就是html的C/S模式嘛!
微软退出WPF,是为了让桌面应用更加美观。我认为其中加入了很多B/S模式的理念,尤其是样式的控制方面。当然,各种控件仍然是我们快速开发的利器。...
分类:
其他好文 时间:
2014-04-29 13:48:20
阅读次数:
248
许多Arduino的项目是基于两个简单的程序。
能所你的电脑所不能的单片机,那就是Arduino。
我们每天使用的计算机是强大的,但他们根本不了解身边发生了什么事。比如说你的笔记本电脑也不能感到光或水。另外,Arduino对外专门设计成键控的。它有一个用于简化传感器通信的输入、输出板子。
Arduino是由Massimo Banzi和他的意大利搭档Ivrea开发的,并由Ivrea,他最喜...
分类:
其他好文 时间:
2014-04-29 13:43:20
阅读次数:
381
刚开始学习Python时,看资料和别人介绍中提到过,安装Python的包有的用easy_install, setuptools, 有的使用pip,distribute。现在把这些相关的资料整理一下,能更清晰的了解Python的设计,关于这些可以参考http://guide.python-distribute.org/installation.html。...
分类:
编程语言 时间:
2014-04-29 13:42:22
阅读次数:
358
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it to ...
分类:
其他好文 时间:
2014-04-29 13:42:21
阅读次数:
427
1、
??
String to Integer (atoi)
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yours...
分类:
其他好文 时间:
2014-04-29 13:22:22
阅读次数:
341
Given n non-negative integers a1, a2,
..., an, where each represents a point at coordinate (i, ai). n vertical
lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
0). Fin...
分类:
其他好文 时间:
2014-04-29 13:15:21
阅读次数:
415
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路同十进制的大数相加。代码如下:
class Solution {
public:
string addBinary(string a, str...
分类:
其他好文 时间:
2014-04-29 13:12:20
阅读次数:
328