关闭

leetcode 53: Maximum Subarray

标签: 面试算法leetcodec++
357人阅读 评论(0) 收藏 举报
分类:

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

For example, given the array [−2,1,−3,4,−1,2,1,−5,4],
the contiguous subarray [4,−1,2,1] has the largest sum = 6.

分治的还没细看
class Solution {
public:
    int maxSubArray(vector& nums) {
        if(nums.size()==0)
            return 0;
        int i=1;
        int j=nums.size();
        int leftMax=nums[0];
        int leftIndex=0;
        int numSum=nums[0];
        while(i
0
0
查看评论

LeetCode53. Maximum Subarray 动态规划和分治法

题意:在一个数组中找到一个和最大的子数组。 有两种方法: 动态规划DP 分治法
  • wmdshhz0404
  • wmdshhz0404
  • 2016-09-20 23:26
  • 387

LeetCode(53)Maximum Subarray

题目如下: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4...
  • feliciafay
  • feliciafay
  • 2014-01-29 11:00
  • 5197

LeetCode 53. Maximum Subarray Java

53. Maximum Subarray   Find the contiguous subarray within an array (containing at least one number) which has the largest su...
  • DuanLiuchang
  • DuanLiuchang
  • 2016-08-11 10:07
  • 961

【leetcode】【53】Maximum Subarray

一、问题描述 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array&#...
  • xiaoliucool1314
  • xiaoliucool1314
  • 2016-03-01 11:21
  • 354

LeetCode-53-Maximum Subarray(DP/分治)-Medium

题意理解: 求解数列中的子数列,要求子数列的和最大; 题目分析: 1. DP(如解题代码所示); 2. 分治(参考http://www.2cto.com/kf/201403/289418.html) 解题代码: class Solution { public: i...
  • eddy_liu
  • eddy_liu
  • 2016-01-16 21:07
  • 945

LeetCode 53 — Maximum Subarray(C++ Java Python)

题目:http://oj.leetcode.com/problems/maximum-subarray/ Find the contiguous subarray within an array (containing at least one number) which has the lar...
  • dragon_dream
  • dragon_dream
  • 2014-02-24 21:57
  • 2839

[LeetCode]53.Maximum Subarray

【题目】 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2...
  • SunnyYoona
  • SunnyYoona
  • 2015-01-27 20:23
  • 1925

leetcode解题之53 # Maximum Subarray Java版

leetcode解题之53 # Maximum Subarray Java版
  • mine_song
  • mine_song
  • 2017-03-12 21:45
  • 209

leetcode第53题-Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4...
  • ZYH920521
  • ZYH920521
  • 2015-06-15 19:35
  • 398

[leetcode]53. Maximum Subarray 最大连续子串python实现【medium】

题目: Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, g...
  • zl87758539
  • zl87758539
  • 2016-06-15 00:30
  • 1819
    个人资料
    • 访问:160037次
    • 积分:3239
    • 等级:
    • 排名:第12452名
    • 原创:154篇
    • 转载:115篇
    • 译文:0篇
    • 评论:3条
    最新评论