数组 数组 数组实际上是由一个变量名称表示的一组同类型的数据元素。每个元素通过变量名称和一个或多个方括号中的索引来访问: 让我们从C#中与数组有关的重要定义开始 元素 数组的独立数据项称为元素。数组的所有元素必须是同类型的,或继承自相同的类型 秩/维度 数组可以有任何为正数的维度数。数组的维度数称作 ...
分类:
编程语言 时间:
2018-12-16 15:23:54
阅读次数:
208
题 Zero Sum Subarray | Data Structure and Algorithm 的变形题,由于要求的子串和不一定,故哈希表的方法不再适用,使用解法4 - 排序即可在 O(nlogn) 内解决。具体步骤如下: C++: 源码分析 为避免对单个子串和是否为最小情形的单独考虑,我们可 ...
分类:
其他好文 时间:
2018-12-15 14:58:12
阅读次数:
163
题解1 - 哈希表 题 Zero Sum Subarray | Data Structure and Algorithm 的升级版,这道题求子串和为 K 的索引。首先我们可以考虑使用时间复杂度相对较低的哈希表解决。前一道题的核心约束条件为 f(i1)?f(i2)=0,这道题则变为 f(i1)?f(i ...
分类:
其他好文 时间:
2018-12-14 17:33:51
阅读次数:
162
563. Binary Tree Tilt 566. Reshape the Matrix 572. Subtree of Another Tree 581. Shortest Unsorted Continuous Subarray ...
分类:
其他好文 时间:
2018-12-04 10:12:53
阅读次数:
175
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3, 2,4], ...
分类:
其他好文 时间:
2018-12-03 00:49:56
阅读次数:
160
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Note: 解法:hash ...
分类:
其他好文 时间:
2018-12-02 12:18:28
阅读次数:
223
https://leetcode.com/problems/minimum-size-subarray-sum/ Given an array of n positive integers and a positive integer s, find the minimal length of a ...
分类:
其他好文 时间:
2018-11-30 20:17:24
阅读次数:
187
这道题是一道我认为非常好的题,它让我初步认识了动态规划思想。先看一下题目描述: 无序的数组中找到一个具有最大和的连续子数组,返回值是和,这道题有许多种解法,但是我思考了20分钟也没有写出来,这篇文章重点说一下用动态规划来解这道题,分治思想另篇说起,先上代码: 非常唯美的代码。简洁明了,这里用到了dp ...
分类:
其他好文 时间:
2018-11-22 18:13:22
阅读次数:
181
https://leetcode.com/problems/maximum-subarray/ Given an integer array nums, find the contiguous subarray (containing at least one number) which has t ...
分类:
其他好文 时间:
2018-11-21 19:42:36
阅读次数:
190
1. Question: 643. Maximum Average Subarray I url https://leetcode.com/problems/maximum-average-subarray-i/ Given an array consisting of n integers, fi ...
分类:
其他好文 时间:
2018-11-20 00:03:09
阅读次数:
199