Skip to content

Commit 4de4804

Browse files
committed
cpp
1 parent 0e6f7a6 commit 4de4804

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
int minOperations(int n) {
4+
5+
int A[n];
6+
7+
for(int i=0;i<n;i++){
8+
A[i]=(2 * i) + 1;
9+
}
10+
11+
int val=A[0]+A[n-1];
12+
13+
val=val/2;
14+
15+
int ans=0;
16+
17+
for(int i=0;i<n/2;i++){
18+
ans+=(val-A[i]);
19+
}
20+
return ans;
21+
}
22+
};

0 commit comments

Comments
 (0)