Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f172fa

Browse files
refactor 1551
1 parent13b97e1 commit9f172fa

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
intmin =1;
77
intmax =2 * (n -1) +1;
88
intfinalNumber = (max +min) /2;
9-
int[]arr =newint[n];
10-
for (inti =0;i <n;i++) {
11-
arr[i] =2 *i +1;
12-
}
139
intops =0;
1410
for (inti =0;i <n /2;i++) {
15-
ops +=finalNumber -arr[i];
11+
ops +=finalNumber -(2 *i +1);
1612
}
1713
returnops;
1814
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp