My DP C++ 9ms Solution, any way optimize?

  • 0

    Here is my solution,
    class Solution {
    int maxSubArray(vector<int>& nums) {
    int sum = 0;
    int max = INT_MIN;
    for(auto i:nums){
    sum = (i>(i+ sum))?i:(i+sum);
    if(max < sum) max = sum;
    return max;

    Some people get 6ms solution, can any one of you post it to me?
    Thanks for help

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.