You are viewing a single comment's thread. Return to all comments →
Anyone can help me to solve this ?
public static long maximumSum(List<long> a, long m) { long res = 0; for(int i = 0; i < a.Count; i++) { long sum = 0; for(int j = i; j < a.Count; j++) { sum = (a[j] + sum) % m; if(sum > res) res = sum; if(res == m-1) return res; } } return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Subarray Sum
You are viewing a single comment's thread. Return to all comments →
C# Solution
9/18 cases passed the others can't pass cause of time limit.
Anyone can help me to solve this ?