摘要:
问题: 给一组数组,对其进行一个排序得到新的数组res,使得对res做一下操作最后得到target为一个递增数组。 1.取第一个数,到target数组。 2.把剩下的第一个数,排到原数组res最后。 3.重复1和2,直到原数组res为空。 Example 1: Input: [17,13,11,2, 阅读全文
摘要:
问题: 给定数组,给数组的一些值+1作为一个move,使得该数组成为一个没有重复元素的递增数组, 求最小的move。 Example 1: Input: [1,2,2] Output: 1 Explanation: After 1 move, the array could be [1, 2, 3] 阅读全文
摘要:
问题: 重新排序给定数组,使得下标index和数值A[index]的奇偶性一致。 Example 1: Input: [4,2,5,7] Output: [4,5,2,7] Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have be 阅读全文
摘要:
问题: 给定一个数组,如过将其中每X个相同的数组成一个group,正好分完,其中X>=2,成立的话,返回true,否则返回false Example 1: Input: deck = [1,2,3,4,4,3,2,1] Output: true Explanation: Possible parti 阅读全文
摘要:
问题: 给定01组成的字符串,求反转(0->1 or 1->0)最少次数,使得成为0...001..11(0..00 or 1..11)这样的单调增字符串。求反转次数。 Example 1: Input: "00110" Output: 1 Explanation: We flip the last 阅读全文
摘要:
问题: 给定数组,判断若为单调增(A[i]>=A[i-1])或者单调减(A[i]<=A[i-1])数组,则返回true,否则返回false。 Example 1: Input: [1,2,2,3] Output: true Example 2: Input: [6,5,4,4] Output: tr 阅读全文
摘要:
问题: 给定一个数组,其为循环数组(最后一个元素的下一个元素为第一个元素)。 求连续子数组和的最大值。 Example 1: Input: [1,-2,3,-2] Output: 3 Explanation: Subarray [3] has maximum sum 3 Example 2: Inp 阅读全文
摘要:
问题: 给定数组,切分为left和right,使得left的所有元素<=right的所有元素,返回left的长度 Example 1: Input: [5,0,3,8,6] Output: 3 Explanation: left = [5,0,3], right = [8,6] Example 2: 阅读全文
摘要:
问题: 数组A,和数组B,求交换两数组任意一个元素,使得两数组和相等。 返回{A交换出的元素,B交换出的元素} Example 1: Input: A = [1,1], B = [2,2] Output: [1,2] Example 2: Input: A = [1,2], B = [2,3] Ou 阅读全文
摘要:
问题: 给定数组,求所有连续子数组的最小值之和。 若所得之数太大,求其mod(10^9 + 7) Example 1: Input: [3,1,2,4] Output: 17 Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [ 阅读全文