上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页
摘要: 问题: 给定一个由0,1 组成的二维数组,0代表海水,1代表陆地, 求给定数组所形成小岛的最大面积。 Example 1: [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], 阅读全文
posted @ 2020-04-20 14:04 habibah_chang 阅读(93) 评论(0) 推荐(0)
摘要: 问题: 给定一个数组,求从中取得3组连续长度为 k 的子数组,使得3组数组和为最大,且使得3组的index尽可能小(★)。 Example: Input: [1,2,1,2,6,7,5,1], 2 Output: [0, 3, 5] Explanation: Subarrays [1, 2], [ 阅读全文
posted @ 2020-04-20 12:51 habibah_chang 阅读(127) 评论(0) 推荐(0)
摘要: 问题: 给定一个n,有数组1~n, 排列该数组,使得数组两两元素之间的差值有k种。 Example 1: Input: n = 3, k = 1 Output: [1, 2, 3] Explanation: The [1, 2, 3] has three different positive int 阅读全文
posted @ 2020-04-19 13:28 habibah_chang 阅读(124) 评论(0) 推荐(0)
摘要: 问题: 给定一个攻击时间点数组,和每一次攻击所持续的时间长度。 求在攻击时间点数组的攻击下,一共能持续多久。 Example 1: Input: [1,4], 2 Output: 4 Explanation: At time point 1, Teemo starts attacking Ashe 阅读全文
posted @ 2020-04-19 11:26 habibah_chang 阅读(96) 评论(0) 推荐(0)
摘要: 问题: 给定数组,nums[i]=k,k!=0 若k>0, 则下一个数的index是向右+|k| 若k<0,则下一个数的index是向左-|k| (数组首尾相连) 这样的移动规则,问是否存在形成一个循环圈的访问环。(该环长度>1,且单向移动) 解法: 快慢指针法 慢指针一次移动一个,快指针一次移动两 阅读全文
posted @ 2020-04-16 16:07 habibah_chang 阅读(93) 评论(0) 推荐(0)
摘要: 问题: 给定一个数组,1 ≤ a[i] ≤ n (n = size of array),其中一些元素出现2次,其他出现1次, 求 出现两次的这些元素。 要求:不借助额外空间,时间复杂度为O(n) 解法: 抓住该题目给定数组的特性: ·所有元素 在1~n之间,可联系到 数值 和 偏移位置 的对应关系。 阅读全文
posted @ 2020-04-16 10:34 habibah_chang 阅读(71) 评论(0) 推荐(0)
摘要: 问题: 设计数据结构,使得以下三个方法的时间复杂度都为O(1) 允许插入重复数字。 insert(val): Inserts an item val to the collection. remove(val): Removes an item val from the collection if 阅读全文
posted @ 2020-04-14 19:42 habibah_chang 阅读(146) 评论(0) 推荐(0)
摘要: 问题: 设计数据结构,使得以下三个方法的时间复杂度都为O(1) insert(val): Inserts an item val to the set if not already present. remove(val): Removes an item val from the set if p 阅读全文
posted @ 2020-04-14 13:33 habibah_chang 阅读(108) 评论(0) 推荐(0)
摘要: 问题: degree:给定数组中重复最多元素的次数 求重复次数为degree的元素中,距离最短子数组的长度。 Example 1: Input: [1, 2, 2, 3, 1] Output: 2 Explanation: The input array has a degree of 2 beca 阅读全文
posted @ 2020-04-12 17:26 habibah_chang 阅读(137) 评论(0) 推荐(0)
摘要: 问题: 给定字符串,返回连续相同字符子串长度>=3的始终位置集合。 Example 1: Input: "abbxxxxzzy" Output: [[3,6]] Explanation: "xxxx" is the single large group with starting 3 and end 阅读全文
posted @ 2020-04-11 11:30 habibah_chang 阅读(130) 评论(0) 推荐(0)
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页