Breadcrumbs leetcode-solutions /cpp / 2542-maximum-subsequence-score.cpp Latest commit mainframer Create 2542-maximum-subsequence-score.cpp 235cea9· Jul 17, 2023 HistoryHistory File metadata and controls Code
0042-trapping-rain-water.cpp 0043-multiply-strings.cpp 0045-jump-game-ii.cpp 0046-permutations.cpp 0048-rotate-image.cpp 0049-group-anagrams.cpp 0050-powx-n.cpp 0051-n-queens.cpp 0052-n-queens-ii.cpp 0053-maximum-subarray.cpp 0054-spiral-matrix.cpp 0055-jump-game.cpp 0056-merge-intervals...
具体实现参考代码。对“分而治之”思想感兴趣的可以参考「算法导论」。 code #include<iostream>#include<vector>#include<algorithm>#include<limits>usingnamespacestd;classSolution{public:intmaxSubArray(vector<int>& nums){intcurSum =0;intmaxSum = numeric_limits<int>::min();for(intn : nums){if(cur...
【LeetCode】164. Maximum Gap (2 solutions) Maximum Gap Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return 0 if the array contains less than 2 elements. You may assume all elements in the ar...
My Leetcode Solutions. Contribute to developer-kush/Leetcode development by creating an account on GitHub.
The lines 2.a and 2.b are simple recursive calls. How to find maximum subarray sum such that the subarray crosses the midpoint? We can easily find the crossing sum in linear time. The idea is simple, find the maximum sum starting from mid point and ending at some point on left of ...