您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页LintCode问题图解-12

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种高效简单的算法方案。

高效简单的算法方案

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务