Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d =
target? Find all unique quadruplets in the array which gives the sum of target.
Note:
Element...
分类:
其他好文 时间:
2015-01-30 19:39:12
阅读次数:
198
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
解题思路:采用中序排列的方法递归地决定每个结点的数值;
#include
#include
#include
using namespace std;
//Definition...
分类:
其他好文 时间:
2015-01-30 16:00:24
阅读次数:
131
Description描述There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers...
分类:
其他好文 时间:
2015-01-29 22:23:58
阅读次数:
258
题目链接:3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
*Elements in a triplet (a...
分类:
其他好文 时间:
2015-01-29 21:11:51
阅读次数:
180
题目:
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new len...
分类:
其他好文 时间:
2015-01-29 17:40:24
阅读次数:
126
Indexing
Matrix Indexing
Accessing Single Elements
可以使用如下语法来调用一个矩阵(Matrix)中的一个特定的元素:
A(row,column):A是变量名,行在前,列在后。例如:
A = magic(4)
A =
16 2 3 13
5 11 10 8
9 ...
分类:
其他好文 时间:
2015-01-29 09:37:27
阅读次数:
225
uva 140 Bandwidth
Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an
ordering on the elements in V, then the bandwidth of a node
v is defined as the maxim...
分类:
其他好文 时间:
2015-01-28 09:51:07
阅读次数:
137
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The...
分类:
其他好文 时间:
2015-01-27 14:57:01
阅读次数:
149
题目:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
我的解法:
(1)算法思想:
二分法,数组的中间点为根节点,然后递归。
(2)代码如下:
{CSDN:CODE:589537}...
分类:
其他好文 时间:
2015-01-26 19:21:31
阅读次数:
136
Given an array S of n integers, are there elements a, b, c in S such that a + b + c =
0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c...
分类:
其他好文 时间:
2015-01-26 13:41:30
阅读次数:
95