Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最大子数组和 #422

Open
Pcjmy opened this issue Jan 26, 2023 · 1 comment
Open

最大子数组和 #422

Pcjmy opened this issue Jan 26, 2023 · 1 comment

Comments

@Pcjmy
Copy link
Contributor

Pcjmy commented Jan 26, 2023

No description provided.

@OLDLAI
Copy link

OLDLAI commented Mar 25, 2023

var maxSubArray = function(nums) {
    let dp = [] ;
    dp[0]=nums[0]
    let max = nums[0];
   for(let i =1; i<nums.length ; i++){
        dp[i]=Math.max(dp[i-1]+nums[i],nums[i])
        max=Math.max(dp[i],max)
    }
    return max;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants