From c1e76aa768463b18a2515104699353ee69cbb0b8 Mon Sep 17 00:00:00 2001 From: Thanh829 <93962044+ThanhNIT@users.noreply.github.com> Date: Wed, 31 Dec 2025 21:42:33 +0700 Subject: [PATCH 1/3] fix sonar for tasks 6-149 --- .../s0006_zigzag_conversion/Solution0006.py | 10 +++---- .../Solution0009_test.py | 6 ++-- .../Solution0010_test.py | 10 +++---- .../Solution0035.py | 4 +-- .../g0001_0100/s0051_n_queens/Solution0051.py | 6 ++-- .../s0052_n_queens_ii/Solution0052.py | 14 ++++----- .../s0057_insert_interval/Solution0057.py | 10 +++---- .../s0061_rotate_list/Solution0061.py | 2 +- .../s0063_unique_paths_ii/Solution0063.py | 30 +++++++++---------- .../s0068_text_justification/Solution0068.py | 14 ++++----- .../s0072_edit_distance/Solution0072.py | 2 +- .../s0074_search_a_2d_matrix/Solution0074.py | 16 +++++----- .../Solution0084.py | 2 -- .../s0101_symmetric_tree/Solution0101.py | 10 +++---- .../Solution0105.py | 2 +- .../Solution0106.py | 2 +- .../g0101_0200/s0112_path_sum/Solution0112.py | 6 ++-- .../s0127_word_ladder/Solution0127.py | 12 ++++---- .../s0139_word_break/Solution0139.py | 4 +-- .../Solution0149.py | 2 +- 20 files changed, 80 insertions(+), 84 deletions(-) diff --git a/src/main/python/g0001_0100/s0006_zigzag_conversion/Solution0006.py b/src/main/python/g0001_0100/s0006_zigzag_conversion/Solution0006.py index 04e559a..3e09c96 100644 --- a/src/main/python/g0001_0100/s0006_zigzag_conversion/Solution0006.py +++ b/src/main/python/g0001_0100/s0006_zigzag_conversion/Solution0006.py @@ -2,17 +2,17 @@ # #2025_07_22_Time_5_ms_(93.09%)_Space_17.85_MB_(70.00%) class Solution: - def convert(self, s: str, numRows: int) -> str: + def convert(self, s: str, num_rows: int) -> str: s_len = len(s) - if numRows == 1: + if num_rows == 1: return s - max_dist = numRows * 2 - 2 + max_dist = num_rows * 2 - 2 buf = [] - for i in range(numRows): + for i in range(num_rows): index = i - if i == 0 or i == numRows - 1: + if i == 0 or i == num_rows - 1: while index < s_len: buf.append(s[index]) index += max_dist diff --git a/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py b/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py index b8d26a3..79791b4 100644 --- a/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py +++ b/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py @@ -3,10 +3,10 @@ class SolutionTest(unittest.TestCase): def test_isPalindrome(self): - self.assertEqual(Solution().isPalindrome(121), True) + self.assertTrue(Solution().isPalindrome(121), True) def test_isPalindrome2(self): - self.assertEqual(Solution().isPalindrome(-121), False) + self.assertFalse(Solution().isPalindrome(-121), False) def test_isPalindrome3(self): - self.assertEqual(Solution().isPalindrome(10), False) + self.assertFalse(Solution().isPalindrome(10), False) diff --git a/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py b/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py index d758fda..4c6f36e 100644 --- a/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py +++ b/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py @@ -3,16 +3,16 @@ class SolutionTest(unittest.TestCase): def test_isMatch(self): - self.assertEqual(Solution().isMatch("aa", "a"), False) + self.assertFalse(Solution().isMatch("aa", "a"), False) def test_isMatch2(self): - self.assertEqual(Solution().isMatch("aa", "a*"), True) + self.assertTrue(Solution().isMatch("aa", "a*"), True) def test_isMatch3(self): - self.assertEqual(Solution().isMatch("ab", ".*"), True) + self.assertTrue(Solution().isMatch("ab", ".*"), True) def test_isMatch4(self): - self.assertEqual(Solution().isMatch("aab", "c*a*b"), True) + self.assertTrue(Solution().isMatch("aab", "c*a*b"), True) def test_isMatch5(self): - self.assertEqual(Solution().isMatch("mississippi", "mis*is*p*."), False) + self.assertFalse(Solution().isMatch("mississippi", "mis*is*p*."), False) diff --git a/src/main/python/g0001_0100/s0035_search_insert_position/Solution0035.py b/src/main/python/g0001_0100/s0035_search_insert_position/Solution0035.py index c932971..d8bf3c2 100644 --- a/src/main/python/g0001_0100/s0035_search_insert_position/Solution0035.py +++ b/src/main/python/g0001_0100/s0035_search_insert_position/Solution0035.py @@ -18,10 +18,8 @@ def searchInsert(self, nums: List[int], target: int) -> int: elif guess < target: low = mid + 1 - if nums[-1] == guess: + if nums[-1] == guess or nums[low] > target: return mid + 1 - elif nums[low] > target: - return mid + 1 else: high = mid - 1 diff --git a/src/main/python/g0001_0100/s0051_n_queens/Solution0051.py b/src/main/python/g0001_0100/s0051_n_queens/Solution0051.py index d54cec8..90c014c 100644 --- a/src/main/python/g0001_0100/s0051_n_queens/Solution0051.py +++ b/src/main/python/g0001_0100/s0051_n_queens/Solution0051.py @@ -31,7 +31,7 @@ def helper(self, n: int, row: int, pos: List[bool], pos2: List[int], ans: List[L def construct(self, n: int, pos: List[int], ans: List[List[str]]): sol = [] for r in range(n): - queenRow = ['.'] * n - queenRow[pos[r]] = 'Q' - sol.append(''.join(queenRow)) + queen_row = ['.'] * n + queen_row[pos[r]] = 'Q' + sol.append(''.join(queen_row)) ans.append(sol) diff --git a/src/main/python/g0001_0100/s0052_n_queens_ii/Solution0052.py b/src/main/python/g0001_0100/s0052_n_queens_ii/Solution0052.py index c9a4213..b41ba9f 100644 --- a/src/main/python/g0001_0100/s0052_n_queens_ii/Solution0052.py +++ b/src/main/python/g0001_0100/s0052_n_queens_ii/Solution0052.py @@ -6,16 +6,16 @@ def totalNQueens(self, n: int) -> int: row = [False] * n col = [False] * n diagonal = [False] * (2 * n - 1) - antiDiagonal = [False] * (2 * n - 1) - return self._totalNQueens(n, 0, row, col, diagonal, antiDiagonal) + anti_diagonal = [False] * (2 * n - 1) + return self._totalNQueens(n, 0, row, col, diagonal, anti_diagonal) - def _totalNQueens(self, n, r, row, col, diagonal, antiDiagonal): + def _totalNQueens(self, n, r, row, col, diagonal, anti_diagonal): if r == n: return 1 count = 0 for c in range(n): - if not row[r] and not col[c] and not diagonal[r + c] and not antiDiagonal[r - c + n - 1]: - row[r] = col[c] = diagonal[r + c] = antiDiagonal[r - c + n - 1] = True - count += self._totalNQueens(n, r + 1, row, col, diagonal, antiDiagonal) - row[r] = col[c] = diagonal[r + c] = antiDiagonal[r - c + n - 1] = False + if not row[r] and not col[c] and not diagonal[r + c] and not anti_diagonal[r - c + n - 1]: + row[r] = col[c] = diagonal[r + c] = anti_diagonal[r - c + n - 1] = True + count += self._totalNQueens(n, r + 1, row, col, diagonal, anti_diagonal) + row[r] = col[c] = diagonal[r + c] = anti_diagonal[r - c + n - 1] = False return count diff --git a/src/main/python/g0001_0100/s0057_insert_interval/Solution0057.py b/src/main/python/g0001_0100/s0057_insert_interval/Solution0057.py index e279381..f21b171 100644 --- a/src/main/python/g0001_0100/s0057_insert_interval/Solution0057.py +++ b/src/main/python/g0001_0100/s0057_insert_interval/Solution0057.py @@ -4,19 +4,19 @@ from typing import List class Solution: - def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: + def insert(self, intervals: List[List[int]], new_interval: List[int]) -> List[List[int]]: n = len(intervals) l = 0 r = n - 1 - while l < n and newInterval[0] > intervals[l][1]: + while l < n and new_interval[0] > intervals[l][1]: l += 1 - while r >= 0 and newInterval[1] < intervals[r][0]: + while r >= 0 and new_interval[1] < intervals[r][0]: r -= 1 res = [[0, 0] for _ in range(l + n - r)] for i in range(l): res[i] = intervals[i][:] - res[l][0] = min(newInterval[0], newInterval[0] if l == n else intervals[l][0]) - res[l][1] = max(newInterval[1], newInterval[1] if r == -1 else intervals[r][1]) + res[l][0] = min(new_interval[0], new_interval[0] if l == n else intervals[l][0]) + res[l][1] = max(new_interval[1], new_interval[1] if r == -1 else intervals[r][1]) for i in range(l + 1, l + n - r): j = r + 1 + i - l - 1 res[i] = intervals[j][:] diff --git a/src/main/python/g0001_0100/s0061_rotate_list/Solution0061.py b/src/main/python/g0001_0100/s0061_rotate_list/Solution0061.py index 180a0f3..ad99528 100644 --- a/src/main/python/g0001_0100/s0061_rotate_list/Solution0061.py +++ b/src/main/python/g0001_0100/s0061_rotate_list/Solution0061.py @@ -24,7 +24,7 @@ def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[ListNode]: return head temp = head # iterate and go to the K+1 th node from the end or count - K - 1 node from start - for i in range(1, count - times): + for _ in range(1, count - times): if temp is not None: temp = temp.next new_head = None diff --git a/src/main/python/g0001_0100/s0063_unique_paths_ii/Solution0063.py b/src/main/python/g0001_0100/s0063_unique_paths_ii/Solution0063.py index 6bfef1b..940dd17 100644 --- a/src/main/python/g0001_0100/s0063_unique_paths_ii/Solution0063.py +++ b/src/main/python/g0001_0100/s0063_unique_paths_ii/Solution0063.py @@ -4,27 +4,27 @@ from typing import List class Solution: - def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int: + def uniquePathsWithObstacles(self, obstacle_grid: List[List[int]]) -> int: # if start point has obstacle, there's no path - if obstacleGrid[0][0] == 1: + if obstacle_grid[0][0] == 1: return 0 - obstacleGrid[0][0] = 1 - m = len(obstacleGrid) - n = len(obstacleGrid[0]) + obstacle_grid[0][0] = 1 + m = len(obstacle_grid) + n = len(obstacle_grid[0]) for i in range(1, m): - if obstacleGrid[i][0] == 1: - obstacleGrid[i][0] = 0 + if obstacle_grid[i][0] == 1: + obstacle_grid[i][0] = 0 else: - obstacleGrid[i][0] = obstacleGrid[i - 1][0] + obstacle_grid[i][0] = obstacle_grid[i - 1][0] for j in range(1, n): - if obstacleGrid[0][j] == 1: - obstacleGrid[0][j] = 0 + if obstacle_grid[0][j] == 1: + obstacle_grid[0][j] = 0 else: - obstacleGrid[0][j] = obstacleGrid[0][j - 1] + obstacle_grid[0][j] = obstacle_grid[0][j - 1] for i in range(1, m): for j in range(1, n): - if obstacleGrid[i][j] == 1: - obstacleGrid[i][j] = 0 + if obstacle_grid[i][j] == 1: + obstacle_grid[i][j] = 0 else: - obstacleGrid[i][j] = obstacleGrid[i - 1][j] + obstacleGrid[i][j - 1] - return obstacleGrid[m - 1][n - 1] + obstacle_grid[i][j] = obstacle_grid[i - 1][j] + obstacle_grid[i][j - 1] + return obstacle_grid[m - 1][n - 1] diff --git a/src/main/python/g0001_0100/s0068_text_justification/Solution0068.py b/src/main/python/g0001_0100/s0068_text_justification/Solution0068.py index bd09219..06db668 100644 --- a/src/main/python/g0001_0100/s0068_text_justification/Solution0068.py +++ b/src/main/python/g0001_0100/s0068_text_justification/Solution0068.py @@ -4,7 +4,7 @@ from typing import List class Solution: - def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: + def fullJustify(self, words: List[str], max_width: int) -> List[str]: # Trying to gauge the number of lines so the list doesn't need to resize output = [] # Setting string capacity also @@ -18,18 +18,18 @@ def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: # tracking line length + #words num_words_on_line += 1 # checking if the next word causes an overflow - if line_total + num_words_on_line + len(words[i + 1]) > maxWidth: + if line_total + num_words_on_line + len(words[i + 1]) > max_width: # if only one word fits on the line... if num_words_on_line == 1: # append word sb.append(words[i]) # pad right with spaces - while line_total < maxWidth: + while line_total < max_width: sb.append(' ') line_total += 1 else: # of extra spaces - extra_sp = (maxWidth - line_total) % (num_words_on_line - 1) + extra_sp = (max_width - line_total) % (num_words_on_line - 1) # Creating the line for j in range(start_word, start_word + num_words_on_line - 1): # appending the word @@ -39,7 +39,7 @@ def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: sb.append(' ') extra_sp -= 1 # appending the rest of the required spaces - max_spaces = max(0, (maxWidth - line_total) // (num_words_on_line - 1)) + max_spaces = max(0, (max_width - line_total) // (num_words_on_line - 1)) sb.append(' ' * max_spaces) # appending the last word of the line sb.append(words[start_word + num_words_on_line - 1]) @@ -57,11 +57,11 @@ def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: for i in range(start_word, len(words)): line_total += len(words[i]) sb.append(words[i]) - if line_total < maxWidth: + if line_total < max_width: sb.append(' ') line_total += 1 # padding right side with spaces - while line_total < maxWidth: + while line_total < max_width: sb.append(' ') line_total += 1 # add the final line to output list diff --git a/src/main/python/g0001_0100/s0072_edit_distance/Solution0072.py b/src/main/python/g0001_0100/s0072_edit_distance/Solution0072.py index 5fe5a28..f6d6829 100644 --- a/src/main/python/g0001_0100/s0072_edit_distance/Solution0072.py +++ b/src/main/python/g0001_0100/s0072_edit_distance/Solution0072.py @@ -14,5 +14,5 @@ def solve(self, str1, i, str2, j, dp): def minDistance(self, word1: str, word2: str) -> int: m,n = len(word1), len(word2) - dp=[[-1]*(n+1) for i in range(m+1)] + dp=[[-1] * (n+1) for _ in range(m + 1)] return self.solve(word1, m, word2, n, dp) diff --git a/src/main/python/g0001_0100/s0074_search_a_2d_matrix/Solution0074.py b/src/main/python/g0001_0100/s0074_search_a_2d_matrix/Solution0074.py index be7a2ff..db35592 100644 --- a/src/main/python/g0001_0100/s0074_search_a_2d_matrix/Solution0074.py +++ b/src/main/python/g0001_0100/s0074_search_a_2d_matrix/Solution0074.py @@ -7,18 +7,18 @@ class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: - endRow = len(matrix) - endCol = len(matrix[0]) - targetRow = 0 + end_row = len(matrix) + end_col = len(matrix[0]) + target_row = 0 result = False - for i in range(endRow): - if matrix[i][endCol - 1] >= target: - targetRow = i + for i in range(end_row): + if matrix[i][end_col - 1] >= target: + target_row = i break - for i in range(endCol): - if matrix[targetRow][i] == target: + for i in range(end_col): + if matrix[target_row][i] == target: result = True break diff --git a/src/main/python/g0001_0100/s0084_largest_rectangle_in_histogram/Solution0084.py b/src/main/python/g0001_0100/s0084_largest_rectangle_in_histogram/Solution0084.py index 9d404e9..3be5412 100644 --- a/src/main/python/g0001_0100/s0084_largest_rectangle_in_histogram/Solution0084.py +++ b/src/main/python/g0001_0100/s0084_largest_rectangle_in_histogram/Solution0084.py @@ -11,8 +11,6 @@ def largestRectangleArea(self, heights: List[int]) -> int: for i,h in enumerate(heights): if h > heights[lefts[-1]]: lefts.append(i) - elif h == heights[lefts[-1]]: - pass elif h < heights[lefts[-1]]: while lefts and h < heights[lefts[-1]]: left = lefts.pop() diff --git a/src/main/python/g0101_0200/s0101_symmetric_tree/Solution0101.py b/src/main/python/g0101_0200/s0101_symmetric_tree/Solution0101.py index 0889f74..9434567 100644 --- a/src/main/python/g0101_0200/s0101_symmetric_tree/Solution0101.py +++ b/src/main/python/g0101_0200/s0101_symmetric_tree/Solution0101.py @@ -22,9 +22,9 @@ def isSymmetric(self, root: Optional[TreeNode]) -> bool: return True return self.helper(root.left, root.right) - def helper(self, leftNode: TreeNode, rightNode: TreeNode) -> bool: - if leftNode is None or rightNode is None: - return leftNode is None and rightNode is None - if leftNode.val != rightNode.val: + def helper(self, left_node: TreeNode, right_node: TreeNode) -> bool: + if left_node is None or right_node is None: + return left_node is None and right_node is None + if left_node.val != right_node.val: return False - return self.helper(leftNode.left, rightNode.right) and self.helper(leftNode.right, rightNode.left) + return self.helper(left_node.left, right_node.right) and self.helper(left_node.right, right_node.left) diff --git a/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py b/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py index 50470a8..ccb885a 100644 --- a/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py +++ b/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py @@ -23,7 +23,7 @@ def __init__(self): def get(self, key: int) -> int: return self.map[key] - def answer(self, preorder: List[int], inorder: List[int], start: int, end: int) -> TreeNode: + def answer(self, preorder: List[int], inorder: List[int], start: int, end: int) -> TreeNode | None: if start > end or self.j > len(preorder): return None value = preorder[self.j] diff --git a/src/main/python/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution0106.py b/src/main/python/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution0106.py index 86cde5b..a5fb538 100644 --- a/src/main/python/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution0106.py +++ b/src/main/python/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution0106.py @@ -15,7 +15,7 @@ def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNo post_index = [len(postorder) - 1] return self._helper(inorder, postorder, in_index, post_index, float('inf')) - def _helper(self, inorder: List[int], postorder: List[int], index: List[int], p_index: List[int], target: int) -> Optional[TreeNode]: + def _helper(self, inorder: List[int], postorder: List[int], index: List[int], p_index: List[int], target: float) -> Optional[TreeNode]: if index[0] < 0 or (index[0] < len(inorder) and inorder[index[0]] == target): return None root = TreeNode(postorder[p_index[0]]) diff --git a/src/main/python/g0101_0200/s0112_path_sum/Solution0112.py b/src/main/python/g0101_0200/s0112_path_sum/Solution0112.py index 6f655d7..d4d5831 100644 --- a/src/main/python/g0101_0200/s0112_path_sum/Solution0112.py +++ b/src/main/python/g0101_0200/s0112_path_sum/Solution0112.py @@ -10,9 +10,9 @@ def __init__(self, val=0, left=None, right=None): self.right = right class Solution: - def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: + def hasPathSum(self, root: Optional[TreeNode], target_sum: int) -> bool: if root is None: return False - if targetSum == root.val and root.left is None and root.right is None: + if target_sum == root.val and root.left is None and root.right is None: return True - return self.hasPathSum(root.left, targetSum - root.val) or self.hasPathSum(root.right, targetSum - root.val) + return self.hasPathSum(root.left, target_sum - root.val) or self.hasPathSum(root.right, target_sum - root.val) diff --git a/src/main/python/g0101_0200/s0127_word_ladder/Solution0127.py b/src/main/python/g0101_0200/s0127_word_ladder/Solution0127.py index f56e8f7..ccc0350 100644 --- a/src/main/python/g0101_0200/s0127_word_ladder/Solution0127.py +++ b/src/main/python/g0101_0200/s0127_word_ladder/Solution0127.py @@ -5,17 +5,17 @@ from typing import List, Set class Solution: - def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: + def ladderLength(self, begin_word: str, end_word: str, word_list: List[str]) -> int: begin_set = set() end_set = set() - word_set = set(wordList) + word_set = set(word_list) visited = set() - if endWord not in wordList: + if end_word not in word_list: return 0 length = 1 - str_len = len(beginWord) - begin_set.add(beginWord) - end_set.add(endWord) + str_len = len(begin_word) + begin_set.add(begin_word) + end_set.add(end_word) while begin_set and end_set: if len(begin_set) > len(end_set): begin_set, end_set = end_set, begin_set diff --git a/src/main/python/g0101_0200/s0139_word_break/Solution0139.py b/src/main/python/g0101_0200/s0139_word_break/Solution0139.py index 4d02274..4b334d4 100644 --- a/src/main/python/g0101_0200/s0139_word_break/Solution0139.py +++ b/src/main/python/g0101_0200/s0139_word_break/Solution0139.py @@ -6,7 +6,7 @@ from typing import List class Solution: - def wordBreak(self, s: str, wordDict: List[str]) -> bool: + def wordBreak(self, s: str, word_dict: List[str]) -> bool: n = len(s) dp = [-1] * n @@ -15,7 +15,7 @@ def solve(i, s): return True if dp[i] != -1: return dp[i] == 1 - for w in wordDict: + for w in word_dict: sz = len(w) if i - sz + 1 >= 0 and s[i - sz + 1 : i + 1] == w: if solve(i - sz, s): diff --git a/src/main/python/g0101_0200/s0149_max_points_on_a_line/Solution0149.py b/src/main/python/g0101_0200/s0149_max_points_on_a_line/Solution0149.py index 5acab8e..863a8c3 100644 --- a/src/main/python/g0101_0200/s0149_max_points_on_a_line/Solution0149.py +++ b/src/main/python/g0101_0200/s0149_max_points_on_a_line/Solution0149.py @@ -20,7 +20,7 @@ def maxPoints(self, points: List[List[int]]) -> int: hashmap[m].add(i) hashmap[m].add(j) else: - hashmap[m] = set([i, j]) + hashmap[m] = {i, j} result = max(len(hashmap[m]), result) return result From 61d58449e710546ec4a380d3c86642448da4b886 Mon Sep 17 00:00:00 2001 From: Thanh829 <93962044+ThanhNIT@users.noreply.github.com> Date: Wed, 31 Dec 2025 22:08:19 +0700 Subject: [PATCH 2/3] Update Solution0105.py --- .../Solution0105.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py b/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py index ccb885a..94bdc79 100644 --- a/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py +++ b/src/main/python/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution0105.py @@ -23,7 +23,7 @@ def __init__(self): def get(self, key: int) -> int: return self.map[key] - def answer(self, preorder: List[int], inorder: List[int], start: int, end: int) -> TreeNode | None: + def answer(self, preorder: List[int], inorder: List[int], start: int, end: int) -> Optional[TreeNode]: if start > end or self.j > len(preorder): return None value = preorder[self.j] From a23d2bb336b9d95de4122a8a430f543a47b90cd8 Mon Sep 17 00:00:00 2001 From: Thanh829 <93962044+ThanhNIT@users.noreply.github.com> Date: Thu, 1 Jan 2026 07:43:44 +0700 Subject: [PATCH 3/3] update --- .../s0009_palindrome_number/Solution0009_test.py | 6 +++--- .../Solution0010_test.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py b/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py index 79791b4..1e8759b 100644 --- a/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py +++ b/src/main/python/g0001_0100/s0009_palindrome_number/Solution0009_test.py @@ -3,10 +3,10 @@ class SolutionTest(unittest.TestCase): def test_isPalindrome(self): - self.assertTrue(Solution().isPalindrome(121), True) + self.assertTrue(Solution().isPalindrome(121)) def test_isPalindrome2(self): - self.assertFalse(Solution().isPalindrome(-121), False) + self.assertFalse(Solution().isPalindrome(-121)) def test_isPalindrome3(self): - self.assertFalse(Solution().isPalindrome(10), False) + self.assertFalse(Solution().isPalindrome(10)) diff --git a/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py b/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py index 4c6f36e..1f5a8f4 100644 --- a/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py +++ b/src/main/python/g0001_0100/s0010_regular_expression_matching/Solution0010_test.py @@ -3,16 +3,16 @@ class SolutionTest(unittest.TestCase): def test_isMatch(self): - self.assertFalse(Solution().isMatch("aa", "a"), False) + self.assertFalse(Solution().isMatch("aa", "a")) def test_isMatch2(self): - self.assertTrue(Solution().isMatch("aa", "a*"), True) + self.assertTrue(Solution().isMatch("aa", "a*")) def test_isMatch3(self): - self.assertTrue(Solution().isMatch("ab", ".*"), True) + self.assertTrue(Solution().isMatch("ab", ".*")) def test_isMatch4(self): - self.assertTrue(Solution().isMatch("aab", "c*a*b"), True) + self.assertTrue(Solution().isMatch("aab", "c*a*b")) def test_isMatch5(self): - self.assertFalse(Solution().isMatch("mississippi", "mis*is*p*."), False) + self.assertFalse(Solution().isMatch("mississippi", "mis*is*p*."))