摘要:Given an array consisting of $n$ integers, find the contiguous subarray of given length $k$ that has the maximum average value. And you need to output
阅读全文
随笔分类 - Leetcode
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.
阅读全文
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say $(a_1, b_1), (a_2, b_2), ..., (a_n, b_n)$ which makes
阅读全文
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1 : Note : The input array will only contain and . The length o
阅读全文
摘要:Given an array of integers where ($n =$ size of array), some elements appear twice and others appear once. Find all the elements of inclusive that do
阅读全文
摘要:Given a non empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexi
阅读全文
摘要:Given an array of integers and an integer $k$, find out whether there are two distinct indices $i$ and $j$ in the array such that nums[i] = nums[j] an
阅读全文
摘要: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
阅读全文
摘要:189. Rotate Array Rotate an array of $n$ elements to the right by $k$ steps. For example, with $n = 7$ and $k = 3$, the array is rotated to . Related
阅读全文
摘要:169. Majority Element Given an array of size $n$, find the majority element. The majority element is the element that appears more than times. You may
阅读全文
摘要:122. Best Time to Buy and Sell Stock II 为获得最高收益而多次买卖,但只能像这样买卖: $O(n)$ time, $O(1)$ space. 自家代码:
阅读全文
摘要:167. Two Sum II Input array is sorted Given an array of integers that is already sorted in ascending order , find two numbers such that they add up to
阅读全文
摘要:121. Best Time to Buy and Sell Stock Example 1: Example 2: 同53题. The maximum (minimum) subarray problem. 用到$DP$. 这题是重点 : 就是序列从A[0]开始计算, 不符合条件就清0, 从断处继
阅读全文
摘要:119. Pascal's Triangle II Given an index $k$, return the $k^{th}$ row of the Pascal's triangle. For example, given $k = 3$, Return . 直接生成由0组成的数组,设定 ,迭
阅读全文
摘要:88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 ha
阅读全文
摘要:118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given , Return 在每一行后面+1, 再更新该行. 另外学会向 容器中放 元素. 人家代
阅读全文
摘要:66. Plus One Given a non negative integer represented as a non empty array of digits, plus one to the integer. 该题目要求:将一整数按位存储在vector中,对其实现+1操作,返回结果. 对
阅读全文
摘要:53. Maximum Subarray 同121题. Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, give
阅读全文
摘要:Given an array , write a function to move all 's to the end of it while maintaining the relative order of the non zero elements. For example, given ,
阅读全文
摘要:268. Missing Number Given an array containing $n$ distinct numbers taken from , find the one that is missing from the array. For example, Given return
阅读全文

浙公网安备 33010602011771号