分析:
* 可以匹配任意个字符,包括0个多个连续的*的作用相当于1个*。* 后无其他字符,则直接匹配出现*p为 *,而*s为字符时,我们有两种选择,一种是跳过*p指示的*,也就是令*匹配0个字符,继续向后匹配。
一种是我们需要用* 匹配多个字符,才能完成匹配。
* 后有其他字符,则在s串中向后找与该非*字符匹配的字符,若没找到,则不匹配,若找到了,则会有不同的情况。
...
分类:
其他好文 时间:
2014-06-02 15:14:29
阅读次数:
271
Best Time to Buy and Sell Stock IISay you have
an array for which theithelement is the price of a given stock on dayi.Design an
algorithm to find the ...
分类:
其他好文 时间:
2014-06-02 15:01:53
阅读次数:
305
在你的王国里有一条n个头的恶龙,你希望雇一些骑士把它杀死(即砍掉所有头)。村里有m个骑士可以雇佣,一个能力值为m的骑士可以砍掉一个直径不超过x的头,且需要支付x个金币。如何雇佣骑士才能砍掉恶龙的所有头,且需要支付的金币最少?注意,一个骑士只能砍一个头(且不能被雇佣两次)。...
分类:
其他好文 时间:
2014-06-02 12:25:09
阅读次数:
193
问题:
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
...
分类:
其他好文 时间:
2014-06-02 05:25:23
阅读次数:
295
class Solution {
public:
void swap(int &a,int &b)
{
int t=a;
a=b;
b=t;
}
void ksort(int l,int h,int a[])
{
if(h<l+2)
return;
int e=h,p=l;
while(...
分类:
其他好文 时间:
2014-06-02 03:01:26
阅读次数:
206
问题:
在Sudoku
Solver 中说道,会有一些提示解,这里就是验证下给定的提示解是否合法,即已经填加的数是否满足要求的三个条件。
bool isValidSudoku(vector > &board) {
const int M = 9;//9 * 9
const int hash_len = 60;//'0' = 48 + 10
const char do...
分类:
其他好文 时间:
2014-06-02 02:31:45
阅读次数:
279
1.MD5加密Message Digest Algorithm
MD5(中文名为消息摘要算法第五版)为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护。该算法的文件号为RFC 1321(R.Rivest,MIT
Laboratory for Computer Science and R...
分类:
移动开发 时间:
2014-06-02 00:37:48
阅读次数:
303
问题:
返回N皇后问题解的个数。
分析:
详见 N-queens
实现:
bool nextPermutation(vector &num)
{
int i = num.size() - 1;
while (i >= 1)
{
if(num[i] > num[i - 1])
{
--i;
int ii = num.size() - 1;
while (i...
分类:
其他好文 时间:
2014-06-01 18:24:45
阅读次数:
398
问题:
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens...
分类:
其他好文 时间:
2014-06-01 18:08:28
阅读次数:
334
MD5(单向散列算法)的全称是Message-Digest Algorithm
5(信息-摘要算法),经MD2、MD3和MD4发展而来。MD5算法的使用不须要支付不论什么版权费用。MD5功能:
输入随意长度的信息,经过处理,输出为128位的信息(数字指纹); 不同的输入得到的不同的结果(唯一性); ...
分类:
其他好文 时间:
2014-06-01 16:48:37
阅读次数:
346