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...
分类:
其他好文 时间:
2015-06-09 11:54:45
阅读次数:
125
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is...
分类:
其他好文 时间:
2015-06-09 11:54:27
阅读次数:
106
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2...
分类:
其他好文 时间:
2015-06-09 11:31:09
阅读次数:
101
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5,
Return[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]分析:
第j=0列全为1,第j==i列时,都为1
其它列
a[2][1]...
分类:
其他好文 时间:
2015-06-09 10:06:02
阅读次数:
132
ListNode *reverseBetween(ListNode* head, int m, int n)
{
if (m == n)
return head;
n -= m;
ListNode prehead(0);
prehead.next = hea...
分类:
其他好文 时间:
2015-06-09 10:01:22
阅读次数:
137
题意:有两个箱子,里面各放有糖n个,每天从两个之中任取一颗糖,突然有一天小孩取糖时发现一个盒子里空了,问另一个盒子里面现在有多少糖(求期望值)?
#include
#include
using namespace std;
double F[400008];
double C_N_M(int n,int m)
{
return F[n]-F[m]-F[n-m];
}
void Ini...
分类:
其他好文 时间:
2015-06-09 10:00:26
阅读次数:
542
wrapper.c
#include
#include
#include
#include
int my_shm_open(char* filename, int open_flag){
int shm_id;
key_t key;
key = ftok(filename, 0x03);
if(key == -1){
return ...
分类:
编程语言 时间:
2015-06-09 09:55:53
阅读次数:
152
题目:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following ma...
分类:
其他好文 时间:
2015-06-09 08:30:13
阅读次数:
106
题目:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3...
分类:
其他好文 时间:
2015-06-09 08:27:01
阅读次数:
79
1、关于函数中的return:在使用 return 语句时,函数会停止执行,并返回指定的值。语法function myFunction(){var x=5;return x;}上面的函数会返回值 5注意:整个 JavaScript 并不会停止执行,仅仅是函数。JavaScript 将继续执行代码,从...
分类:
Web程序 时间:
2015-06-09 06:06:26
阅读次数:
97