摘要: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two di 阅读全文
posted @ 2020-07-02 23:06 whatyouthink 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
posted @ 2020-07-02 22:58 whatyouthink 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr 阅读全文
posted @ 2020-07-02 20:21 whatyouthink 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Say you have an array prices for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may 阅读全文
posted @ 2020-07-02 20:11 whatyouthink 阅读(97) 评论(0) 推荐(0) 编辑
摘要: An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. A 阅读全文
posted @ 2020-07-02 20:04 whatyouthink 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Element at grid[i][j] moves to grid[i][j + 阅读全文
posted @ 2020-07-02 19:59 whatyouthink 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smallest character in s. For example, if s = "dcce" then 阅读全文
posted @ 2020-07-02 11:41 whatyouthink 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time. Return that in 阅读全文
posted @ 2020-07-02 11:06 whatyouthink 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of ca 阅读全文
posted @ 2020-07-02 10:29 whatyouthink 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2020-07-02 10:13 whatyouthink 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: 阅读全文
posted @ 2020-07-02 10:06 whatyouthink 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Ra 阅读全文
posted @ 2020-07-02 09:53 whatyouthink 阅读(91) 评论(0) 推荐(0) 编辑