求和最大的连续子串

6-05 1,833 views

思路:
采用动态规划进行求解,令:
maxSum[k]表示子串list{0,k}的最大连续子串和,
maxSumIncludeK[k]表示子串list{0,k}中末尾为k的最大连续子串和,

maxSumIncludeK[k] = max(list[k],list[k]+maxSumIncludeK[k-1]),
maxSum[k] = max(maxSumIncludeK[k],maxSum[k-1])。
代码:

001000729

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For exa...

阅读全文

Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ...

阅读全文

Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space...

阅读全文