Skip to content

Commit a026881

Browse files
committed
Update maximum gap
1 parent b2bd14c commit a026881

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Hard/MaximumGap.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616
class MaximumGap {
1717
public static void main(String[] args) {
18-
System.out.println(maximumGap(new int[]{3, 6, 9, 1}));
18+
MaximumGap mg = new MaximumGap();
19+
System.out.println(mg.maximumGap(new int[]{3, 6, 9, 1}));
1920
}
2021

2122
/**
@@ -24,9 +25,9 @@ public static void main(String[] args) {
2425
* Calculate bucket length and divide numbers into buckets
2526
* Traverse buckets to find max gap
2627
*/
27-
public static int maximumGap(int[] num) {
28-
int n;
29-
if (num == null || (n = num.length) < 2) return 0;
28+
public int maximumGap(int[] num) {
29+
if (num == null || num.length < 2) return 0;
30+
int n = num.length;
3031
/*find max and min value*/
3132
int min = num[0];
3233
int max = num[0];

Hard/SudokuSolver.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99
*/
1010
class SudokuSolver {
1111
public static void main(String[] args) {
12-
12+
char[][] board = {
13+
{'.', '.', '9', '7', '4', '8', '.', '.', '.'},
14+
{'7', '.', '.', '.', '.', '.', '.', '.', '.'},
15+
{'.', '2', '.', '1', '.', '9', '.', '.', '.'},
16+
{'.', '.', '7', '.', '.', '.', '2', '4', '.'},
17+
{'.', '6', '4', '.', '1', '.', '5', '9', '.'},
18+
{'.', '9', '8', '.', '.', '.', '3', '.', '.'},
19+
{'.', '.', '.', '8', '.', '3', '.', '2', '.'},
20+
{'.', '.', '.', '.', '.', '.', '.', '.', '6'},
21+
{'.', '.', '.', '2', '7', '5', '9', '.', '.'}
22+
};
23+
SudokuSolver s = new SudokuSolver();
24+
s.solveSudoku(board);
25+
for (int i = 0; i < board.length; i++) {
26+
for (int j = 0; j < board[i].length; j++) {
27+
System.out.print(board[i][j] + " ");
28+
}
29+
System.out.println();
30+
}
1331
}
1432

1533
int[] row, col, sqr;

0 commit comments

Comments
 (0)