题目如下: Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1: Input: A = [4,5, ...
分类:
其他好文 时间:
2019-01-25 11:36:20
阅读次数:
165
传送门:点我 978. Longest Turbulent Subarray 978. Longest Turbulent Subarray A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: ...
分类:
编程语言 时间:
2019-01-23 23:25:39
阅读次数:
317
Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1: Input: A = [4,5,0,-2,- ...
分类:
其他好文 时间:
2019-01-13 13:45:16
阅读次数:
365
第一题: 973. K Closest Points to Origin 973. K Closest Points to Origin We have a list of points on the plane. Find the K closest points to the origin (0 ...
分类:
其他好文 时间:
2019-01-13 13:42:40
阅读次数:
199
The maximum subarray problem is one of the nicest examples of dynamic programming application. In this lesson we cover an example of how this problem ...
分类:
编程语言 时间:
2019-01-06 10:37:13
阅读次数:
180
然后看了一下讨论 思路大概就是建立一个dp矩阵,然后将每一个数,到它自身这个位置时的最大值保存起来。这样就只用遍历一次,时间复杂度为O(n) ...
分类:
其他好文 时间:
2019-01-03 13:59:51
阅读次数:
149
Question Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C. Here, a circular array mea ...
分类:
其他好文 时间:
2019-01-02 10:47:18
阅读次数:
282
上学期转专业就没怎么学好数据结构,这学期正好看了算法导论第四章也有讲动态规划和,正好前不久做那个查找最长不重样字符串的题学了一个最短字符串匹配的动态图框法。用动态规划写了一下,分治还没写出来。 不止一次在if(x=1)这种问题上犯错了,要注意。有数组里只有一个数,和全是负数的情况要处理。 ...
分类:
其他好文 时间:
2018-12-24 02:35:39
阅读次数:
80
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll ...
分类:
其他好文 时间:
2018-12-23 11:08:05
阅读次数:
144
双索引技术(Two Pointer) 滑动窗口:这两个索引表示的是一个窗口,让这个窗口不停的在数组中滑动,来找到问题的解。 -什么叫子数组:可以不连续。但是本题强调了是要连续的。、 解法一:滑动窗口 时间复杂度:O(n),空间复杂度O(1) 因为没有另外开辟空间。 思路:和209类似采用滑动窗口的思 ...
分类:
其他好文 时间:
2018-12-22 01:28:21
阅读次数:
379