上一页 1 2 3 4 5 6 ··· 16 下一页
摘要: Description Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The algorithm should run in linear time and 阅读全文
posted @ 2020-04-16 12:56 bw98 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Description Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may ass 阅读全文
posted @ 2020-04-15 14:56 bw98 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Description Given a non negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. In Pa 阅读全文
posted @ 2020-04-14 17:30 bw98 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Description Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length = 3 There exists some 0 B[i+1] ... B[B 阅读全文
posted @ 2020-04-12 18:07 bw98 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Description Given an unsorted integer array, find the smallest missing positive integer. Example 1: Example 2: Example 3: Note: Your algorithm should 阅读全文
posted @ 2020-04-10 19:48 bw98 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Description Shuffle a set of numbers without duplicates. Example: 思路 分析洗牌算法正确性的准则:产生的结果必须有 n! 种可能,否则就是错误的。这个很好解释,因为一个长度为 n 的数组的全排列就有 n! 种,也就是说打乱结果总共有 阅读全文
posted @ 2020-04-10 01:18 bw98 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Description Given an array, rotate the array to the right by k steps, where k is non negative. Example 1: Example 2: Note: Try to come up as many solu 阅读全文
posted @ 2020-04-09 01:49 bw98 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Description 思路 解法一 构造一个已排好序的辅助数组。从该数组开始位置开始往后线性扫描,两两数组相互比较,当数字不同时进行处理,让 指向要处理的序列的最左端, 指向最右端。最后左右夹逼出来的子数组就是需要被升序排序的子数组。 耗时 116 ms, ranking 5% cpp class 阅读全文
posted @ 2020-04-08 00:46 bw98 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Description 思路 老年人回炉重造第6天。 这道题和 442 是同类型的题,比较tricky,要求时间复杂度 ,no extra space(题目补充说明了待返回的数组不算在 extra space 里,所以可以开辟一个数组保存算法的结果) 本题的难点之一是如何正确理解题目,关键信息有两个 阅读全文
posted @ 2020-04-06 15:47 bw98 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Description Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements tha 阅读全文
posted @ 2020-04-05 15:19 bw98 阅读(135) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 16 下一页