【题目】
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
/ 2 2
/ \ / 3 4 4 3
But the following is not:
1
/ 2 2
\ 3 3
No...
分类:
其他好文 时间:
2014-06-02 10:56:14
阅读次数:
237
问题:
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
问题:
在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
下午一个人在望江东路18楼屋里,等另一个人回来,颓废时默默祈祷自己想要的会让自己更充实和智慧,可如果不能完全形成习惯,完全靠意志力无法完全让自己长期处于这样的状态。这是自己有感而发的想法,或许在另一个时空状态下是错的,但人活着必须要有种坚定不移相信的状态。这一周又要过去了,先做个自我检讨和总结,在....
分类:
其他好文 时间:
2014-06-01 23:39:50
阅读次数:
237
问题:
返回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
1.#import跟#include、@class有什么区别?#import<>跟#import”"又什么区别?1>#import和#include都能完整地包含某个文件的内容,#import能防止同一个文件被包含多次2>@class仅仅是声明一个类名,并不会包含类的完整声明;@class还能解决循环包含的问题3>#impor..
分类:
移动开发 时间:
2014-06-01 16:37:35
阅读次数:
336
问题:
给定一个字符串数组words,一个整数L,将words中的字符串按行编辑,L表示每行的长度。
要求:
1)每个单词之间至少是有一个空格隔开的。
2)最后一行每个单词间只间隔一个空格, 最后一个单词后不足L长度的用空格填充。
3)除最后一行外,其他行进行填充长度的空格要均分,不能均分的,将余数代表的空格数依次填充在行左。
For example,
words: ["Th...
分类:
其他好文 时间:
2014-06-01 15:43:03
阅读次数:
297
题目:
给定一个字符串S,一个字符串数组L,找出S中所有这样的子串起点,该子串包含L中的所有元素。
说明:
1)L中存在重复的元素
2)子串不允许间断,即子串从开始到找全L中的所有元素之前,子串中不允许包含L以外的东西,而且,即使当前处理的子串是L中含有的,但是前面已经找够了,这个多余的也是不合法的,若此时还有L中的其他元素没找到,从这个起点开始也是不成功的。
3)L在S中出现的...
分类:
其他好文 时间:
2014-06-01 12:54:53
阅读次数:
192