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

Commit4d66eb6

Browse files
edit 532
1 parentfd03eb3 commit4d66eb6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
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

‎src/main/java/com/fishercoder/solutions/KdiffPairsinanArray.javarenamed to‎src/main/java/com/fishercoder/solutions/_532.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
importjava.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-
publicclassKdiffPairsinanArray {
30+
publicclass_532 {
3031

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

‎src/test/java/com/fishercoder/KdiffPairsinanArrayTest.javarenamed to‎src/test/java/com/fishercoder/_532Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
packagecom.fishercoder;
22

3-
importcom.fishercoder.solutions.KdiffPairsinanArray;
3+
importcom.fishercoder.solutions._532;
44
importorg.junit.Before;
55
importorg.junit.BeforeClass;
66
importorg.junit.Test;
77

88
importstaticjunit.framework.Assert.assertEquals;
99

10-
publicclassKdiffPairsinanArrayTest {
11-
privatestaticKdiffPairsinanArraytest;
10+
publicclass_532Test {
11+
privatestatic_532test;
1212
privatestaticintexpected;
1313
privatestaticintactual;
1414
privatestaticintk;
1515
privatestaticint[]nums;
1616

1717
@BeforeClass
1818
publicstaticvoidsetup() {
19-
test =newKdiffPairsinanArray();
19+
test =new_532();
2020
}
2121

2222
@Before

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp