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 13b97e1 commit 9f172faCopy full SHA for 9f172fa
src/main/java/com/fishercoder/solutions/_1551.java
@@ -6,13 +6,9 @@ public int minOperations(int n) {
6
int min = 1;
7
int max = 2 * (n - 1) + 1;
8
int finalNumber = (max + min) / 2;
9
- int[] arr = new int[n];
10
- for (int i = 0; i < n; i++) {
11
- arr[i] = 2 * i + 1;
12
- }
13
int ops = 0;
14
for (int i = 0; i < n / 2; i++) {
15
- ops += finalNumber - arr[i];
+ ops += finalNumber - (2 * i + 1);
16
}
17
return ops;
18
0 commit comments