File tree 7 files changed +167
-6
lines changed
solution/3500-3599/3523.Make Array Non-decreasing
7 files changed +167
-6
lines changed Original file line number Diff line number Diff line change @@ -75,25 +75,79 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3523.Ma
75
75
#### Python3
76
76
77
77
``` python
78
-
78
+ class Solution :
79
+ def maximumPossibleSize (self , nums : List[int ]) -> int :
80
+ ans = mx = 0
81
+ for x in nums:
82
+ if mx <= x:
83
+ ans += 1
84
+ mx = x
85
+ return ans
79
86
```
80
87
81
88
#### Java
82
89
83
90
``` java
84
-
91
+ class Solution {
92
+ public int maximumPossibleSize (int [] nums ) {
93
+ int ans = 0 , mx = 0 ;
94
+ for (int x : nums) {
95
+ if (mx <= x) {
96
+ ++ ans;
97
+ mx = x;
98
+ }
99
+ }
100
+ return ans;
101
+ }
102
+ }
85
103
```
86
104
87
105
#### C++
88
106
89
107
``` cpp
90
-
108
+ class Solution {
109
+ public:
110
+ int maximumPossibleSize(vector<int >& nums) {
111
+ int ans = 0, mx = 0;
112
+ for (int x : nums) {
113
+ if (mx <= x) {
114
+ ++ans;
115
+ mx = x;
116
+ }
117
+ }
118
+ return ans;
119
+ }
120
+ };
91
121
```
92
122
93
123
#### Go
94
124
95
125
```go
126
+ func maximumPossibleSize(nums []int) int {
127
+ ans, mx := 0, 0
128
+ for _, x := range nums {
129
+ if mx <= x {
130
+ ans++
131
+ mx = x
132
+ }
133
+ }
134
+ return ans
135
+ }
136
+ ```
96
137
138
+ #### TypeScript
139
+
140
+ ``` ts
141
+ function maximumPossibleSize(nums : number []): number {
142
+ let [ans, mx] = [0 , 0 ];
143
+ for (const x of nums ) {
144
+ if (mx <= x ) {
145
+ ++ ans ;
146
+ mx = x ;
147
+ }
148
+ }
149
+ return ans ;
150
+ }
97
151
```
98
152
99
153
<!-- tabs: end -->
Original file line number Diff line number Diff line change @@ -71,25 +71,79 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3523.Ma
71
71
#### Python3
72
72
73
73
``` python
74
-
74
+ class Solution :
75
+ def maximumPossibleSize (self , nums : List[int ]) -> int :
76
+ ans = mx = 0
77
+ for x in nums:
78
+ if mx <= x:
79
+ ans += 1
80
+ mx = x
81
+ return ans
75
82
```
76
83
77
84
#### Java
78
85
79
86
``` java
80
-
87
+ class Solution {
88
+ public int maximumPossibleSize (int [] nums ) {
89
+ int ans = 0 , mx = 0 ;
90
+ for (int x : nums) {
91
+ if (mx <= x) {
92
+ ++ ans;
93
+ mx = x;
94
+ }
95
+ }
96
+ return ans;
97
+ }
98
+ }
81
99
```
82
100
83
101
#### C++
84
102
85
103
``` cpp
86
-
104
+ class Solution {
105
+ public:
106
+ int maximumPossibleSize(vector<int >& nums) {
107
+ int ans = 0, mx = 0;
108
+ for (int x : nums) {
109
+ if (mx <= x) {
110
+ ++ans;
111
+ mx = x;
112
+ }
113
+ }
114
+ return ans;
115
+ }
116
+ };
87
117
```
88
118
89
119
#### Go
90
120
91
121
```go
122
+ func maximumPossibleSize(nums []int) int {
123
+ ans, mx := 0, 0
124
+ for _, x := range nums {
125
+ if mx <= x {
126
+ ans++
127
+ mx = x
128
+ }
129
+ }
130
+ return ans
131
+ }
132
+ ```
92
133
134
+ #### TypeScript
135
+
136
+ ``` ts
137
+ function maximumPossibleSize(nums : number []): number {
138
+ let [ans, mx] = [0 , 0 ];
139
+ for (const x of nums ) {
140
+ if (mx <= x ) {
141
+ ++ ans ;
142
+ mx = x ;
143
+ }
144
+ }
145
+ return ans ;
146
+ }
93
147
```
94
148
95
149
<!-- tabs: end -->
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ int maximumPossibleSize (vector<int >& nums) {
4
+ int ans = 0 , mx = 0 ;
5
+ for (int x : nums) {
6
+ if (mx <= x) {
7
+ ++ans;
8
+ mx = x;
9
+ }
10
+ }
11
+ return ans;
12
+ }
13
+ };
Original file line number Diff line number Diff line change
1
+ func maximumPossibleSize (nums []int ) int {
2
+ ans , mx := 0 , 0
3
+ for _ , x := range nums {
4
+ if mx <= x {
5
+ ans ++
6
+ mx = x
7
+ }
8
+ }
9
+ return ans
10
+ }
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public int maximumPossibleSize (int [] nums ) {
3
+ int ans = 0 , mx = 0 ;
4
+ for (int x : nums ) {
5
+ if (mx <= x ) {
6
+ ++ans ;
7
+ mx = x ;
8
+ }
9
+ }
10
+ return ans ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def maximumPossibleSize (self , nums : List [int ]) -> int :
3
+ ans = mx = 0
4
+ for x in nums :
5
+ if mx <= x :
6
+ ans += 1
7
+ mx = x
8
+ return ans
Original file line number Diff line number Diff line change
1
+ function maximumPossibleSize ( nums : number [ ] ) : number {
2
+ let [ ans , mx ] = [ 0 , 0 ] ;
3
+ for ( const x of nums ) {
4
+ if ( mx <= x ) {
5
+ ++ ans ;
6
+ mx = x ;
7
+ }
8
+ }
9
+ return ans ;
10
+ }
You can’t perform that action at this time.
0 commit comments