Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9f172fa

Browse files
refactor 1551
1 parent 13b97e1 commit 9f172fa

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/java/com/fishercoder/solutions/_1551.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ public int minOperations(int n) {
66
int min = 1;
77
int max = 2 * (n - 1) + 1;
88
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-
}
139
int ops = 0;
1410
for (int i = 0; i < n / 2; i++) {
15-
ops += finalNumber - arr[i];
11+
ops += finalNumber - (2 * i + 1);
1612
}
1713
return ops;
1814
}

0 commit comments

Comments
 (0)