![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Array
lpcarl
这个作者很懒,什么都没留下…
展开
-
LeetCode刷题——Array篇(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.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one ...原创 2018-04-16 16:22:48 · 124 阅读 · 0 评论 -
LeetCode刷题——Array篇(Product of Array Except Self)
Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Example:Input: [1,2,3,4] Output: ...原创 2018-05-10 11:42:29 · 147 阅读 · 0 评论 -
LeetCode刷题——Array篇(Find All Duplicates in an Array)
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 that appear twice in this array.Could you do it without extra ...原创 2018-05-10 11:37:44 · 162 阅读 · 0 评论 -
LeetCode刷题——Array篇(Array Nesting)
A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], … } subjected to the rule below.Suppose ...原创 2018-05-10 15:57:46 · 172 阅读 · 0 评论 -
LeetCode刷题——Array篇(Maximum Subarray)
Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4], O...原创 2018-04-20 14:56:35 · 223 阅读 · 0 评论 -
LeetCode刷题——Array篇(Move Zeroes和Remove Element)
Move ZeroesGiven 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.For example, given nums = [0, 1, 0, 3, 12], after ca...原创 2018-04-19 21:07:17 · 200 阅读 · 0 评论 -
LeetCode刷题——Array篇(Maximum Average Subarray I)
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 the maximum average value.Example 1: Input: [1,12,...原创 2018-04-23 17:40:56 · 155 阅读 · 0 评论 -
LeetCode刷题——Array篇(Two Sum)
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...原创 2018-04-23 14:50:39 · 189 阅读 · 0 评论 -
LeetCode刷题——Array篇(Find Pivot Index)
Given an array of integers nums, write a method that returns the “pivot” index of this array.We define the pivot index as the index where the sum of the numbers to the left of the index is equal to ...原创 2018-04-23 11:14:21 · 197 阅读 · 0 评论 -
LeetCode刷题——Array篇(Best Time to Buy and Sell Stock)
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), d...原创 2018-04-18 16:26:17 · 215 阅读 · 0 评论 -
LeetCode刷题——Array篇(Min Cost Climbing Stairs)
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of ...原创 2018-04-18 15:10:19 · 138 阅读 · 0 评论 -
LeetCode刷题——Array篇(Degree of an Array)
Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length of a ...原创 2018-04-18 14:16:36 · 123 阅读 · 0 评论 -
LeetCode刷题——Array篇(对角线相等)
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input: matrix = [...转载 2018-04-12 14:27:57 · 341 阅读 · 0 评论 -
LeetCode刷题——Array篇(最大岛屿)
1、Max Area of IslandGiven a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges ...转载 2018-04-12 14:19:13 · 402 阅读 · 0 评论 -
LeetCode刷题——Array篇(寻找两数和)
167. Two Sum II - Input array is sortedGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum ...转载 2018-04-16 17:18:47 · 133 阅读 · 0 评论 -
LeetCode刷题——Array篇(Max Chunks To Make Sorted)
Given an array arr that is a permutation of [0, 1, …, arr.length - 1], we split the array into some number of “chunks” (partitions), and individually sort each chunk. After concatenating them, the re...原创 2018-05-17 15:16:48 · 169 阅读 · 0 评论