LintCode问题图解-12

本文准备讲解1个算法编程问题, 这个算法编程问题来自LintCode平台。不了解.LintCode平台的读者可以阅读笔者文章(在线编程平台推荐-LeetCode)。问题的英文版本描述如下:

Continuous Subarray Sum

Given an integer array, find a continuous subarray where the sum of numbers is the biggest. Your code should return the index of the first number and the index of the last number. (If their are duplicate answer, return anyone)

Example

Give[-3, 1, 3, -3, 4], return [1,4].

连续数组元素求和

给定一个整数数组,请找出一个连续数组元素序列,使得该数组元素序列的和最大。输出答案时,请分别返回第一个数字和最后一个数字的下标。(如果存在多个答案,请返回其中任意一个答案)


这道题目是1个很好的题目,但是没有多种效能接近的算法处理方案。现在公布1种高效简单的算法方案。


LintCode问题图解-12_第1张图片
高效简单的算法方案

你可能感兴趣的:(LintCode问题图解-12)