随笔分类 - leetcode
摘要:问题: 给定一组数字,将其等分成k个个数相同的子数组。 求划分后,得到所有子数组最小差分和。 差分:子数组中,最大值-最小值 Example 1: Input: nums = [1,2,1,4], k = 2 Output: 4 Explanation: The optimal distributi
阅读全文
posted @ 2021-02-21 15:07
habibah_chang
摘要:问题: 用a,e,i,o,u构成字符串,前面的字符一定是后面字符的字母序之前。 构成长度为n的字符串,有多少种方法。 Example 1: Input: n = 1 Output: 5 Explanation: The 5 sorted strings that consist of vowels
阅读全文
posted @ 2021-02-14 16:41
habibah_chang
摘要:问题: 给定一组数,将其分配给多个用户, 每个用户要求quantity[i]个相同的数。 问是否能够分配完。 Example 1: Input: nums = [1,2,3,4], quantity = [2] Output: false Explanation: The 0th customer
阅读全文
posted @ 2021-02-14 14:46
habibah_chang
摘要:问题: 给定n个节点,以及节点直接的连线数组edges 已知,这些节点代表城市,这些城市构成一棵树, 即任意两节点都有唯一路径。 求,这些城市中的子树中,各个最大路径的子树个数。 Example 1: Input: n = 4, edges = [[1,2],[2,3],[2,4]] Output:
阅读全文
posted @ 2021-02-13 13:30
habibah_chang
摘要:问题: 将给定的字符串s,最多能够分割成多少个互不重复的字符串? Example 1: Input: s = "ababccc" Output: 5 Explanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Spl
阅读全文
posted @ 2021-02-12 09:33
habibah_chang
摘要:参考:花花酱的解 问题: 给定c_n个颜色的多个球。balls[i]表示:第i个颜色的球数。 将这些球平均分装两个盒子。每个盒子球数相同。 求最终两个盒子中球色种类数相同的装法概率。 Example 1: Input: balls = [1,1] Output: 1.00000 Explanatio
阅读全文
posted @ 2021-02-11 14:01
habibah_chang
摘要:问题: 求由n个字符构成,按照字母序排序后,第k个happy string。 happy string定义: consists only of letters of the set ['a', 'b', 'c']. 仅由a,b,c构成 s[i] != s[i + 1] for all values
阅读全文
posted @ 2021-02-10 09:34
habibah_chang
摘要:问题: 给定一组字符串,和一个结果字符串,使用0~9对字母进行编码。 使得字符串数组相加后,结果=结果字符串。 求是否可能存在这样的编码。 Each character is decoded as one digit (0 - 9). Every pair of different characte
阅读全文
posted @ 2021-02-07 12:37
habibah_chang
摘要:问题: 给定长宽m,n的矩形,将其划分为多个正方形,最少能划分多少个。 Example 1: Input: n = 2, m = 3 Output: 3 Explanation: 3 squares are necessary to cover the rectangle. 2 (squares o
阅读全文
posted @ 2021-02-07 08:24
habibah_chang
摘要:问题: 给定一组字符串数组, 有这些字符串合并构成不存在重复字符的“集连字符串” 求该集连字符串最大长度。 Example 1: Input: arr = ["un","iq","ue"] Output: 4 Explanation: All possible concatenations are
阅读全文
posted @ 2021-02-06 09:03
habibah_chang
摘要:问题: 给定一个二维数组表示藏金矿地图,每个cell表示所在位置藏有的金矿量, 求从任意一个cell开始走地图,不走走过的cell,不走金矿量=0的cell,只能从当前cell的上下左右四个方向进行下一步移动。 最终能获得的最大金矿量。 Example 1: Input: grid = [[0,6,
阅读全文
posted @ 2021-02-06 07:07
habibah_chang
摘要:问题: 给定一个范围[low, high], 求所有在这个范围的数(从小到大排序后的),要求:这些数的后一位数字比前一位数字大一。 Example 1: Input: low = 100, high = 300 Output: [123,234] Example 2: Input: low = 10
阅读全文
posted @ 2021-02-01 15:53
habibah_chang
摘要:问题: 设计一个组合指针类,通过给定组合元素characters,要求构成组合的大小combinationLength,实现以下方法 构造方法:CombinationIterator(string characters, int combinationLength) 返回下一个组合:next() 是
阅读全文
posted @ 2021-01-30 18:03
habibah_chang
摘要:问题:给定一串由A~Z构成的字符串(允许重复)。 从中选取任意个字符,构成新的字符串,求可构成的字符串个数。 Example 1: Input: tiles = "AAB" Output: 8 Explanation: The possible sequences are "A", "B", "AA
阅读全文
posted @ 2021-01-30 13:12
habibah_chang
摘要:问题: 给定一组数,将其排列 使得相邻两个数的和,正好是一个可被平方的数。 求所有的排列可能个数。 Example 1: Input: [1,17,8] Output: 2 Explanation: [1,8,17] and [17,8,1] are the valid permutations.
阅读全文
posted @ 2021-01-29 16:28
habibah_chang
摘要:问题: 给定一个棋盘, 0:可以走的路径 1:起点(有且只有一个) 2:终点(有且只有一个) -1:障碍物,不可走的路径 求从起点到终点,走遍所有可走路径(仅经过一次),的所有路线的可能数。 Example 1: Input: [[1,0,0,0],[0,0,0,0],[0,0,2,-1]] Out
阅读全文
posted @ 2021-01-29 15:05
habibah_chang
摘要:问题: 求位数为n,相邻数字之间绝对值为k的所有数的可能性。 Example 1: Input: n = 3, k = 7 Output: [181,292,707,818,929] Explanation: Note that 070 is not a valid number, because
阅读全文
posted @ 2021-01-29 14:15
habibah_chang
摘要:问题: 给定由数字构成的字符串,对其进行分割,使得构成斐波那契数列。 返回一个解。 Example 1: Input: "123456579" Output: [123,456,579] Example 2: Input: "11235813" Output: [1,1,2,3,5,8,13] Ex
阅读全文
posted @ 2021-01-28 16:04
habibah_chang
摘要:问题: 给定一个【0~n-1】n个节点构成的有向图, 求从0到n-1的所有路径。 graph[i]=[a,b,c...] 指:节点i 指向 节点a,b,c... Example 1: Input: graph = [[1,2],[3],[3],[]] Output: [[0,1,3],[0,2,3]
阅读全文
posted @ 2021-01-28 09:36
habibah_chang
摘要:问题: 给定一个由字母和数字组成的字符串。 任意字母可以变换大小写,以组成新的字符串。 求给定字符串能够组成字符串的所有可能。 Example 1: Input: S = "a1b2" Output: ["a1b2","a1B2","A1b2","A1B2"] Example 2: Input: S
阅读全文
posted @ 2021-01-27 14:14
habibah_chang

浙公网安备 33010602011771号