diff --git a/src/main/java/com/cool/hot100/backtracking/Num79.java b/src/main/java/com/cool/hot100/backtracking/Num79.java new file mode 100644 index 0000000..a6c483e --- /dev/null +++ b/src/main/java/com/cool/hot100/backtracking/Num79.java @@ -0,0 +1,54 @@ +package com.cool.hot100.backtracking; + +/** + * Created with IntelliJ IDEA. + * + * @Author: Cool + * @Date: 2024/09/11/21:21 + * DayNumber 1 + * Hard 2 + * Level 4 + */ +public class Num79 { + + public boolean exist(char[][] board, String word) { + if (board.length < 1) { + return false; + } + for (int i = 0; i < board.length; i++) { + for (int j = 0; j < board[0].length; j++) { + if (board[i][j] == word.charAt(0)) { + if (dfs(board, word, i, j, 0)) { + return true; + } + } + + } + } + return false; + } + + private boolean dfs(char[][] chars, String word, int x, int y, int index) { + if (index == word.length()) { + return true; + } + if (x < 0 || x >= chars.length || y < 0 || y >= chars[0].length) { + return false; + } + if (chars[x][y] == '1') { + return false; + } + boolean is = false; + if (word.charAt(index) == chars[x][y]) { + char temp = chars[x][y]; + chars[x][y] = '1'; + is =dfs(chars, word, x + 1, y, index + 1) || dfs(chars, word, x, y + 1, index + 1) + || dfs(chars, word, x - 1, y, index + 1) || dfs(chars, word, x, y - 1, index + 1); + chars[x][y] = temp; + return is; + } else { + return false; + } + } + +} diff --git a/src/main/java/com/cool/week414/Problem1.java b/src/main/java/com/cool/week414/Problem1.java new file mode 100644 index 0000000..f91617b --- /dev/null +++ b/src/main/java/com/cool/week414/Problem1.java @@ -0,0 +1,36 @@ +package com.cool.week414; + +/** + * Created with IntelliJ IDEA. + * + * @Author: Cool + * @Date: 2024/09/08/11:28 + * ProblemNumber + */ +public class Problem1 { + public String convertDateToBinary(String date) { + String[] dates=date.split("-"); + String res=""; + for(int i=0;i