Skip to content

Commit 118c080

Browse files
refactor 1228
1 parent 3df1a82 commit 118c080

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

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

+6-23
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,11 @@
66
import java.util.List;
77
import java.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
public class _1228 {
3110
public static class Solution1 {
32-
/**A super verbose and inefficient but working way...*/
11+
/**
12+
* A super verbose and inefficient but working way...
13+
*/
3314
public int missingNumber(int[] arr) {
3415
Arrays.sort(arr);
3516
Map<Integer, List<Integer>> map = new HashMap<>();
@@ -50,7 +31,9 @@ public int missingNumber(int[] arr) {
5031
}
5132

5233
public static class Solution2 {
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
public int missingNumber(int[] arr) {
5538
int min = arr[0];
5639
int max = arr[0];

0 commit comments

Comments
 (0)