-
Given a collection of intervals, merge all overlapping intervals.
For example,
Given[1,3],[2,6],[8,10],[15,18],
return[1,6],[8,10],[15,18]. ...
阅读题目
面试题
经典指数
-
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, 9, 4 ],
[ 7, 6, 5 ]
] ...
阅读题目
面试题
经典指数
-
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
Note:
You are not suppose to use the library's sort function for this problem.
click to show follow up.
Follow up:
A rather straight forward solution is a two-pass algorithm using counting sort.
First, iterate the array cou ...
阅读题目
面试题
经典指数
-
-
-
-
【题目】:输入一个非负整形数组,其中每个数代表紧挨着的宽为1的墙的高度,输出这些墙之间能积水的体积。函数接口为 int
Volume(int * height,int n),要求只能遍历一遍数组,且空间复杂度为O(1)。
【示例】:input:([1,0,2,1,0,1,3,2,1,2,1],11)(如下图所示),output:6。 ...
阅读题目
问答题
经典指数
扫描后移动端查看
相关标签
同类标签
|
微信公众号
|
|
欢迎加入,一起群聊
|