Skip to content

Commit 4d66eb6

Browse files
edit 532
1 parent fd03eb3 commit 4d66eb6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Your ideas/fixes/algorithms are more than welcome!
9595
|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_536.java) | O(n) |O(h) | Medium | Recursion
9696
|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_535.java) | O(1) |O(n) | Medium | Design
9797
|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_533.java) | O(m*n) |O(m) (m is number of rows) | Medium | HashMap
98-
|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/KdiffPairsinanArray.java) | O(n) |O(n) | Easy | HashMap
98+
|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_532.java) | O(n) |O(n) | Easy | HashMap
9999
|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_531.java) | O(m*n) |O(1) | Medium |
100100
|530|[Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MinimumAbsoluteDifferenceinBST.java) | O(n) |O(n) | Easy| DFS
101101
|529|[Minesweeper](https://leetcode.com/problems/minesweeper/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_529.java) | O(m*n) |O(k) | Medium | BFS

Diff for: src/main/java/com/fishercoder/solutions/KdiffPairsinanArray.java renamed to src/main/java/com/fishercoder/solutions/_532.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import java.util.*;
44

55
/**
6-
* Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k.
6+
* Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array.
7+
* Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k.
78
89
Example 1:
910
Input: [3, 1, 4, 1, 5], k = 2
@@ -26,7 +27,7 @@ The pairs (i, j) and (j, i) count as the same pair.
2627
The length of the array won't exceed 10,000.
2728
All the integers in the given input belong to the range: [-1e7, 1e7].
2829
*/
29-
public class KdiffPairsinanArray {
30+
public class _532 {
3031

3132
//this O(n^2) will result in TLE
3233
public int findPairs_On2(int[] nums, int k) {

Diff for: src/test/java/com/fishercoder/KdiffPairsinanArrayTest.java renamed to src/test/java/com/fishercoder/_532Test.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package com.fishercoder;
22

3-
import com.fishercoder.solutions.KdiffPairsinanArray;
3+
import com.fishercoder.solutions._532;
44
import org.junit.Before;
55
import org.junit.BeforeClass;
66
import org.junit.Test;
77

88
import static junit.framework.Assert.assertEquals;
99

10-
public class KdiffPairsinanArrayTest {
11-
private static KdiffPairsinanArray test;
10+
public class _532Test {
11+
private static _532 test;
1212
private static int expected;
1313
private static int actual;
1414
private static int k;
1515
private static int[] nums;
1616

1717
@BeforeClass
1818
public static void setup() {
19-
test = new KdiffPairsinanArray();
19+
test = new _532();
2020
}
2121

2222
@Before

0 commit comments

Comments
 (0)