Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't ...
分类:
其他好文 时间:
2018-06-16 10:28:25
阅读次数:
183
https://code.google.com/codejam/contest/4384486/dashboard s=p0 A 题意 给定一个无向图,其中存在着唯一的一个环,求每个点到这个环的最短距离。 数据范围 ≤ T ≤ 100. 1 ≤ xi ≤ N, for all i. 1 ≤ yi ≤ ...
分类:
其他好文 时间:
2018-06-14 11:39:47
阅读次数:
161
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be ...
分类:
其他好文 时间:
2018-06-08 00:49:56
阅读次数:
178
这个方法很骚,线性时间,解释一波 从前向后扫描,maxele存放从nums[0]到nums[i]之间的最大元素,和当前元素比较,若当前元素nums[i]小于这个最大值,则更新end 从后往前扫描,minele存放从nums[sz-1]到当前元素中的最小值,和当前于元素比较,若当前元素大于这个最小值, ...
分类:
其他好文 时间:
2018-06-05 21:07:47
阅读次数:
95
question: Give the sequence of subarray sizes in the merges performed by both the top-down and the bottom-up mergesort algorithms, for N = 39. answer: ...
分类:
其他好文 时间:
2018-05-31 19:21:43
阅读次数:
181
class Solution { public: bool checkSubarraySum(vector& nums, int k) { unordered_map m; // 从头元素开始的sum,取模为key的index。 m[0] = -1; int _sum = 0; for (int i... ...
分类:
其他好文 时间:
2018-05-29 23:35:55
阅读次数:
273
Description Description Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first numbe ...
分类:
编程语言 时间:
2018-05-26 13:02:43
阅读次数:
156
原题网址:https://www.lintcode.com/problem/maximum-subarray-difference/description 描述 给定一个整数数组,找出两个不重叠的子数组A和B,使两个子数组和的差的绝对值|SUM(A) - SUM(B)|最大。 返回这个最大的差值。 ...
分类:
编程语言 时间:
2018-05-25 00:24:39
阅读次数:
221
Description Given an array of integers, find a contiguous subarray which has the largest sum. Given an array of integers, find a contiguous subarray w ...
分类:
其他好文 时间:
2018-05-22 22:05:05
阅读次数:
136
class Solution { public: int minSubArrayLen(int s, vector& nums) { int w = 0, _sum = 0, res = INT_MAX; for (int i = 0; i = s) { res = min(res, i-w+1);... ...
分类:
其他好文 时间:
2018-05-21 14:28:29
阅读次数:
138