We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e8833a commit 162f23fCopy full SHA for 162f23f
1793.好子数组的最大分数/solution.cpp
@@ -0,0 +1,26 @@
1
+class Solution {
2
+public:
3
+ int maximumScore(vector<int>& nums, int k) {
4
+ int sz=nums.size();
5
+ int l=k,r=k;
6
+ int mi=nums.at(k);
7
+ int ans=nums.at(k);
8
+ while (l!=0 || r!=sz-1) {
9
+ if (l==0) {
10
+ r++;
11
+ mi=min(mi,nums.at(r));
12
+ } else if (r==sz-1) {
13
+ l--;
14
+ mi=min(mi,nums.at(l));
15
+ } else if (nums.at(l-1)>nums.at(r+1)){
16
17
18
+ } else {
19
20
21
+ }
22
+ ans=max(ans,mi*(r-l+1));
23
24
+ return ans;
25
26
+};
0 commit comments