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

Commit118c080

Browse files
refactor 1228
1 parent3df1a82 commit118c080

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

‎src/main/java/com/fishercoder/solutions/_1228.java

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,11 @@
66
importjava.util.List;
77
importjava.util.Map;
88

9-
/**
10-
* 1228. Missing Number In Arithmetic Progression
11-
*
12-
* In some array arr, the values were in arithmetic progression: the values arr[i+1] - arr[i] are all equal for every 0 <= i < arr.length - 1.
13-
* Then, a value from arr was removed that was not the first or last value in the array.
14-
* Return the removed value.
15-
*
16-
* Example 1:
17-
* Input: arr = [5,7,11,13]
18-
* Output: 9
19-
* Explanation: The previous array was [5,7,9,11,13].
20-
*
21-
* Example 2:
22-
* Input: arr = [15,13,12]
23-
* Output: 14
24-
* Explanation: The previous array was [15,14,13,12].
25-
*
26-
* Constraints:
27-
* 3 <= arr.length <= 1000
28-
* 0 <= arr[i] <= 10^5
29-
* */
309
publicclass_1228 {
3110
publicstaticclassSolution1 {
32-
/**A super verbose and inefficient but working way...*/
11+
/**
12+
* A super verbose and inefficient but working way...
13+
*/
3314
publicintmissingNumber(int[]arr) {
3415
Arrays.sort(arr);
3516
Map<Integer,List<Integer>>map =newHashMap<>();
@@ -50,7 +31,9 @@ public int missingNumber(int[] arr) {
5031
}
5132

5233
publicstaticclassSolution2 {
53-
/**credit: https://leetcode.com/problems/missing-number-in-arithmetic-progression/discuss/408474/JavaC%2B%2BPython-Arithmetic-Sum-and-Binary-Search*/
34+
/**
35+
* credit: https://leetcode.com/problems/missing-number-in-arithmetic-progression/discuss/408474/JavaC%2B%2BPython-Arithmetic-Sum-and-Binary-Search
36+
*/
5437
publicintmissingNumber(int[]arr) {
5538
intmin =arr[0];
5639
intmax =arr[0];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp