随笔分类 -  leetcode

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 19 下一页
摘要:问题: 给出某年某月某日,求该天是周几? Example 1: Input: day = 31, month = 8, year = 2019 Output: "Saturday" Example 2: Input: day = 18, month = 7, year = 1999 Output: 阅读全文
posted @ 2020-07-06 14:19 habibah_chang
摘要:问题: 给定一个二维数组, 求其中正方形区域,使得和<=阈值threshold的最长边长。 Example 1: Input: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4 Output: 2 Expla 阅读全文
posted @ 2020-07-05 10:59 habibah_chang
摘要:问题: 给定n个汽车站之间的距离数组distances(相邻两个站相连,收尾站相连,可顺时针逆时针两个方向行驶) 求start站和destination站之间的最短距离。 Example 1: Input: distance = [1,2,3,4], start = 0, destination = 阅读全文
posted @ 2020-07-05 09:54 habibah_chang
摘要:问题: 给定一组目标字符串数组 queries,和一个参照系字符串数组 words 求queries中的各个字符串:最小字符出现次数< words中最小字符出现次数的参照字符串的个数。 记字符串出现最小次数为函数fun Example 1: Input: queries = ["cbd"], wor 阅读全文
posted @ 2020-07-05 09:33 habibah_chang
摘要:问题: 给定数组,和整数k 是否能将数组 刚好平均分配为,每k个一组连续递增子数组。 Example 1: Input: nums = [1,2,3,3,4,4,5,6], k = 4 Output: true Explanation: Array can be divided into [1,2, 阅读全文
posted @ 2020-07-04 20:22 habibah_chang
摘要:问题: 给定一个数组,对所有元素进行,按大小排名rank,同样大小排名相同。 Example 1: Input: arr = [40,10,20,30] Output: [4,1,2,3] Explanation: 40 is the largest element. 10 is the small 阅读全文
posted @ 2020-07-04 14:27 habibah_chang
摘要:问题: 给定一个数组,相邻两两元素构成编码,第一个元素代表出现次数,第二个元素代表出现的元素。 求编码前的原数组。 Example 1: Input: nums = [1,2,3,4] Output: [2,4,4,4] Explanation: The first pair [1,2] means 阅读全文
posted @ 2020-07-04 13:34 habibah_chang
摘要:问题: 给定由0,1构成的数组,求由1构成的(各种长度边长的)正方形的总个数有多少。 Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Explanation: There are 10 squares 阅读全文
posted @ 2020-06-29 19:49 habibah_chang
摘要:问题: 替换当前元素为,当前元素以后元素的最大值。 最后一个元素替换为-1。 Example 1: Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Constraints: 1 <= arr.length <= 10^4 1 <= arr[i 阅读全文
posted @ 2020-06-29 14:30 habibah_chang
摘要:问题: 给定一个服务器所在位置的数组,1代表有一个服务器,0代表没有 若多个服务器,在一行or在一列,则说这些服务器互相连接。 求互相连接的服务器有多少台。 Example 1: Input: grid = [[1,0],[0,1]] Output: 0 Explanation: No server 阅读全文
posted @ 2020-06-29 13:01 habibah_chang
摘要:问题: 给出一个数组,求至少拿出几个元素,使得他们出现的次数之和,>=总元素个数的一半 Example 1: Input: arr = [3,3,3,3,5,5,5,2,2,7] Output: 2 Explanation: Choosing {3,7} will make the new arra 阅读全文
posted @ 2020-06-28 13:17 habibah_chang
摘要:问题: 给出一组全路径文件数组,删除子目录。 Example 1: Input: folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"] Output: ["/a","/c/d","/c/f"] Explanation: Folders "/a/b/" is a 阅读全文
posted @ 2020-06-28 12:42 habibah_chang
摘要:问题: 给定由【姓名,时间,数额,城市】组成的交易信息数组。 求无效交易的数组。 无效:1 or 2满足 1,数额>1000 2,相同姓名,不同城市,时间差<60 Example 1: Input: transactions = ["alice,20,800,mtv","alice,50,100,b 阅读全文
posted @ 2020-06-28 11:53 habibah_chang
摘要:问题: 对二维数组,对角线排序 Example 1: Input: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]] Output: [[1,1,1,1],[1,2,2,2],[1,2,3,3]] Constraints: m == mat.length n == mat[ 阅读全文
posted @ 2020-06-27 13:37 habibah_chang
摘要:问题: 数组快照问题: 1. 初始化长度为length的数组:SnapshotArray 2. 向数组第x位插入数字val:set(int index, int val) 3. 对当前状态对数组做快照(返回值位当前快照id):snap() 4. 获取快照id为snap_id时,数组第index位上的 阅读全文
posted @ 2020-06-27 12:48 habibah_chang
摘要:问题: 给出数对构成的数组dominoes,若其中一对数对dominoes[i]和另一对数对dominoes[j]包含两个数字相同(忽略顺序),那么称这两对数对等价, 求给定数组dominoes,有多少对(i,j)为等价数对。 Example 1: Input: dominoes = [[1,2], 阅读全文
posted @ 2020-06-27 10:46 habibah_chang
摘要:问题: 给定8*8棋盘中,queen的坐标,和king的坐标。 king的同一行,同一列,同一对角线上的第一个queen,为可攻击king的queen 求所有可攻击king的queen的坐标数组。 Example 1: Input: queens = [[0,1],[1,0],[4,0],[0,4] 阅读全文
posted @ 2020-06-21 14:56 habibah_chang
摘要:问题: 给定一个递增数组,求其中出现频率>25%的元素 Example 1: Input: arr = [1,2,2,6,6,6,6,7,10] Output: 6 Constraints: 1 <= arr.length <= 10^4 0 <= arr[i] <= 10^5 解法一: 出现频率> 阅读全文
posted @ 2020-06-21 11:49 habibah_chang
摘要:问题: 给定两个等长字符串s和t,相同index上的元素差值为cost 求cost和最大不超过maxCost,所满足的最长子串的长度。 Example 1: Input: s = "abcd", t = "bcdf", maxCost = 3 Output: 3 Explanation: "abc" 阅读全文
posted @ 2020-06-21 11:10 habibah_chang
摘要:问题: 给定一个包含0的数组,对数组进行遇到0,则再输出一次,后续元素向后推移。 求的转换后的数组。 Example 1: Input: [1,0,2,3,0,4,5,0] Output: null Explanation: After calling your function, the inpu 阅读全文
posted @ 2020-06-20 15:59 habibah_chang

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 19 下一页