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-02-05 10:53:08
阅读次数:
131
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
Try to solve it in linear time/space.
Return 0 if the array contains less than 2 elements. ...
分类:
其他好文 时间:
2015-02-05 09:38:18
阅读次数:
271
【题目】
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
For example,
Given n = 3,
You should return the following matrix:
[
[ 1, 2, 3 ],
[ 8,...
分类:
其他好文 时间:
2015-02-04 23:29:21
阅读次数:
236
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-02-04 18:44:19
阅读次数:
127
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ...
分类:
其他好文 时间:
2015-02-04 18:03:07
阅读次数:
163
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-02-04 14:46:28
阅读次数:
151
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-02-04 09:34:11
阅读次数:
193
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6,...
分类:
其他好文 时间:
2015-02-03 22:44:12
阅读次数:
236
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-02-03 09:35:05
阅读次数:
134
Given an array where elements are sorted in ascending order, convert it toa height balanced BST.
HideTags
Tree Depth-first
Search
#pragma once
#include
#include
using namespace std;...
分类:
其他好文 时间:
2015-02-02 23:14:33
阅读次数:
181