style: enable NeedBraces in checkstyle (#5227)

* enable style NeedBraces

* style: enable NeedBraces in checkstyle

---------

Co-authored-by: Samuel Facchinello <samuel.facchinello@piksel.com>
This commit is contained in:
Samuel Facchinello
2024-06-13 21:00:16 +02:00
committed by GitHub
parent 51fcc66345
commit 87b17e0571
68 changed files with 629 additions and 261 deletions

View File

@ -43,7 +43,9 @@ public final class 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) {
if (index + length - currSet.size() > arr.length) return;
if (index + length - currSet.size() > arr.length) {
return;
}
if (length - 1 == currSet.size()) {
for (int i = index; i < arr.length; i++) {
currSet.add(arr[i]);

View File

@ -59,7 +59,9 @@ public final class MColoring {
// If number of colors used exceeds m,
// return 0
maxColors = Math.max(maxColors, Math.max(nodes.get(top).color, nodes.get(it).color));
if (maxColors > m) return 0;
if (maxColors > m) {
return 0;
}
// If the adjacent node is not visited,
// mark it visited and push it in queue

View File

@ -51,7 +51,9 @@ public class WordSearch {
int yi = y + dy[i];
if (isValid(xi, yi) && board[xi][yi] == word.charAt(nextIdx) && !visited[xi][yi]) {
boolean exists = doDFS(xi, yi, nextIdx + 1);
if (exists) return true;
if (exists) {
return true;
}
}
}
visited[x][y] = false;
@ -66,7 +68,9 @@ public class WordSearch {
if (board[i][j] == word.charAt(0)) {
visited = new boolean[board.length][board[0].length];
boolean exists = doDFS(i, j, 1);
if (exists) return true;
if (exists) {
return true;
}
}
}
}