题目

An array is monotonic if it is either monotone increasing or monotone decreasing.

An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].

Return true if and only if the given array A is monotonic.

- 查看完整题目和思路 -

题目

In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.

There is at least one empty seat, and at least one person sitting.

Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.

Return that maximum distance to closest person.

- 查看完整题目和思路 -

题目

一个魔法方块是一个3x3的矩阵,矩阵内的每个值是1-9的不重复数字,并且其每行,每列和对角线的和都相等。

给一个整数矩阵,找出这个矩阵中有多少个上面说的魔法方快。(每一个子矩阵都是连续的)。

- 查看完整题目和思路 -

题目

有一个小写字母的字符串,这个字符串有一些连续相同的字符。

比如,字符串S="abbxxxxxzyy"有这些连续的字符"a","bb","xxxx","z","yy"。

如果一个字符连续至少出现了3次,我们称它为large group。写一个函数,传入该字符串,然后返回一个数组,然后返回这个字符串所有的large group,需要注意的是,每一个数组的项是一个整数数组,数组的两个值分别代表该large group字符开始和结束的下标。需要注意的是,只有一个字符串至少连续出现3次才能纳入这个返回的数组结果集中。

同时,最后的结果需要按照字典序排序。(但是实际上我看leetcode并没有这样,所以,你也可以不用管这个case)。

- 查看完整题目和思路 -