mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 11:10:08 +08:00
Add automatic linter (#4214)
This commit is contained in:
@ -58,8 +58,7 @@ public class AllPathsFromSourceToTarget {
|
||||
// A recursive function to print all paths from 'u' to 'd'.
|
||||
// isVisited[] keeps track of vertices in current path.
|
||||
// localPathList<> stores actual vertices in the current path
|
||||
private void storeAllPathsUtil(
|
||||
Integer u, Integer d, boolean[] isVisited, List<Integer> localPathList) {
|
||||
private void storeAllPathsUtil(Integer u, Integer d, boolean[] isVisited, List<Integer> localPathList) {
|
||||
|
||||
if (u.equals(d)) {
|
||||
nm.add(new ArrayList<>(localPathList));
|
||||
@ -87,8 +86,7 @@ public class AllPathsFromSourceToTarget {
|
||||
}
|
||||
|
||||
// Driver program
|
||||
public static List<List<Integer>> allPathsFromSourceToTarget(
|
||||
int vertices, int[][] a, int source, int destination) {
|
||||
public static List<List<Integer>> allPathsFromSourceToTarget(int vertices, int[][] a, int source, int destination) {
|
||||
// Create a sample graph
|
||||
AllPathsFromSourceToTarget g = new AllPathsFromSourceToTarget(vertices);
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -37,8 +37,7 @@ public class Combination {
|
||||
* @param result the list contains all combination.
|
||||
* @param <T> the type of elements in the array.
|
||||
*/
|
||||
private static <T> void backtracking(
|
||||
T[] arr, int index, TreeSet<T> currSet, List<TreeSet<T>> result) {
|
||||
private static <T> void backtracking(T[] arr, int index, TreeSet<T> currSet, List<TreeSet<T>> result) {
|
||||
if (index + length - currSet.size() > arr.length) return;
|
||||
if (length - 1 == currSet.size()) {
|
||||
for (int i = index; i < arr.length; i++) {
|
||||
|
@ -47,8 +47,7 @@ public class NQueens {
|
||||
List<List<String>> arrangements = new ArrayList<List<String>>();
|
||||
getSolution(queens, arrangements, new int[queens], 0);
|
||||
if (arrangements.isEmpty()) {
|
||||
System.out.println("There is no way to place " + queens + " queens on board of size "
|
||||
+ queens + "x" + queens);
|
||||
System.out.println("There is no way to place " + queens + " queens on board of size " + queens + "x" + queens);
|
||||
} else {
|
||||
System.out.println("Arrangement for placing " + queens + " queens");
|
||||
}
|
||||
@ -66,8 +65,7 @@ public class NQueens {
|
||||
* @param columns: columns[i] = rowId where queen is placed in ith column.
|
||||
* @param columnIndex: This is the column in which queen is being placed
|
||||
*/
|
||||
private static void getSolution(
|
||||
int boardSize, List<List<String>> solutions, int[] columns, int columnIndex) {
|
||||
private static void getSolution(int boardSize, List<List<String>> solutions, int[] columns, int columnIndex) {
|
||||
if (columnIndex == boardSize) {
|
||||
// this means that all queens have been placed
|
||||
List<String> sol = new ArrayList<String>();
|
||||
|
Reference in New Issue
Block a user