Skip to content

Commit

Permalink
Update Sudoku_Solver.java
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmita authored Apr 1, 2021
1 parent 6885c74 commit 1c8b0a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Code/Java/Sudoku_Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Scanner;
class Sudoku_Solver
{
//A function to check whether a number between 1 to n can be placed at the specified cell or not
public static boolean CanPlace(int[][] mat, int n, int i, int j, int num)
{
//check for rows and columns
Expand All @@ -32,6 +33,7 @@ public static boolean CanPlace(int[][] mat, int n, int i, int j, int num)
return true;
}

//A function to solve the Sudoku, once solved it prints the solution and returns true, otherwise false
public static boolean SudokuSolver(int[][] mat, int n, int i, int j)
{
//base case
Expand Down Expand Up @@ -144,6 +146,6 @@ public static void main(String[] args)
Output:
No Solution!
TIME COMPLEXITY: O(9^(n*n)), as there will be 9 options from 1 to 9 to fill in an empty cell
SPACE COMPLEXITY: O(n*n)
TIME COMPLEXITY: O(9^(n*n)), as there will be 9 options from 1 to 9 to fill in an empty cell.
SPACE COMPLEXITY: O(n*n), where n denotes the size of Sudoku grid
*/

0 comments on commit 1c8b0a5

Please sign in to comment.