
数组
文章平均质量分 73
普通网友
这个作者很懒,什么都没留下…
展开
-
LeetCode 169 Majority Element
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 assume that the array is non-empty and the majority element原创 2018-01-21 16:36:30 · 192 阅读 · 0 评论 -
LeetCode 153 Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exis...原创 2018-02-15 11:23:17 · 169 阅读 · 0 评论 -
LeetCode 689 Maximum Sum of 3 Non-Overlapping Subarrays
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.Return the result ...原创 2018-02-15 10:24:21 · 335 阅读 · 0 评论 -
LeetCode 621 Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could b...原创 2018-02-15 10:08:10 · 186 阅读 · 0 评论 -
LeetCode 287 Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fi...原创 2018-02-15 09:58:47 · 182 阅读 · 0 评论 -
LeetCode 667 Beautiful Arrangement II
Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3,原创 2018-01-21 00:05:38 · 214 阅读 · 0 评论 -
LeetCode 718 Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated sub原创 2018-01-28 23:32:54 · 229 阅读 · 0 评论 -
LeetCode 122 Best Time to Buy and Sell Stock II
这个题和Best Time to Buy and Sell Stock 是有关的。先看下Best Time to Buy and Sell Stock II:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitt原创 2018-01-23 14:56:35 · 153 阅读 · 0 评论 -
LeetCode 532 K-diff Pairs in an Array
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in原创 2018-01-23 14:38:58 · 196 阅读 · 0 评论 -
LeetCode 496 Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. T...原创 2018-02-18 18:31:18 · 194 阅读 · 0 评论