https://oj.leetcode.com/problems/trapping-rain-water/模拟题,计算出在凹凸处存水量。对于一个位置 i ,分别计算出它左边的最大值 left (从左扫描一遍), 右边的最大值 right(从右扫描一遍) 。找left right中的最小值,如果大于 ...
分类:
移动开发 时间:
2014-06-28 16:32:30
阅读次数:
222
You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb...
分类:
其他好文 时间:
2014-06-24 10:22:48
阅读次数:
214
一个男女搭配的关系图,看可以凑成多少对,基本和最原始的一个二分图谜题一样了,就是 一个岛上可以凑成多少对夫妻的问题。
所以是典型的二分图问题。
使用匈牙利算法,写成两个函数,就非常清晰了。
本程序还带分配释放程序,当然oj一般不需要。但是好的程序一定要。
#include
#include
int K, M, N, a, b;
int *linker;
bool **gra, *use...
分类:
其他好文 时间:
2014-06-22 21:50:52
阅读次数:
164
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2014-06-18 13:29:31
阅读次数:
214
原题如下,意思就是说无序数组(由0,1,2组成),一遍扫描,把数组整理成0,1,2这样的序列。
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,...
分类:
其他好文 时间:
2014-06-18 07:12:43
阅读次数:
174
1、
??
Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m =
2 and n = 4,
return 1->4->3->2->5->NULL....
分类:
其他好文 时间:
2014-06-17 23:03:12
阅读次数:
257
/*声明一个类模板,利用它分别实现两个整数.
浮点数和字符的比较,求出大数和小数。
说明:在类模板外定义各成员函数。
输入两个整数、两个浮点数和两个字符
从大到小输出两个整数、两个浮点数和两个字符
*/
#include
#include
using namespace std;
template
class Compare
{
public:
Compare...
分类:
其他好文 时间:
2014-06-17 19:08:27
阅读次数:
266
刚刚A了那题之后 想到以前自己的OJ那边有个整数划分...同时 tz 那边也有个很相似的 我是做了TZ的再做了自己OJ的 一起 放上链接 touch me touch me其实 我们解决的问题 应该主要是 字典序的输出和不能重复的输出就是说 1+1+2出现了 那么1+2+1就不应该出现 -- ...
分类:
其他好文 时间:
2014-06-14 22:49:58
阅读次数:
273
原始题目如下,意为寻找数组和最大的子串,返回这个最大和即可。
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [?2,1,?3,4,?1,2,1,?5,4],
the...
分类:
其他好文 时间:
2014-06-14 15:08:00
阅读次数:
224
1、
??
Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return ...
分类:
其他好文 时间:
2014-06-14 14:11:27
阅读次数:
315