From baf5892352782826611cf38874893335f3f4a49c Mon Sep 17 00:00:00 2001 From: Jack Yao <105488074+StarsExpress@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:42:06 -0500 Subject: [PATCH 1/4] Added black linter & clang format linter. --- .github/workflows/black-lint.yml | 31 +++++++++++++++ .github/workflows/clang-format-lint.yml | 39 +++++++++++++++++++ .github/workflows/deploy.yml | 5 ++- .gitignore | 2 - README.md | 4 ++ config.py | 6 +-- docs/bfs/0987_hard/vertical_traversal.cpp | 3 +- docs/bfs/0987_hard/vertical_traversal.py | 2 +- docs/bfs/1466_medium/reordered_routes.cpp | 3 +- docs/bfs/1466_medium/reordered_routes.py | 2 +- docs/dfs/0329_hard/max_rising_path.cpp | 3 +- docs/dfs/0329_hard/max_rising_path.py | 30 +++++++++----- docs/dfs/2360_hard/longest_cycle.cpp | 3 +- docs/dfs/2360_hard/longest_cycle.py | 3 +- docs/dfs/2876_hard/visited_nodes.cpp | 3 +- docs/dfs/2876_hard/visited_nodes.py | 7 ++-- .../0552_hard/student_attendance.cpp | 3 +- .../0552_hard/student_attendance.py | 11 +++--- .../0918_medium/circular_subarray_sum.cpp | 2 +- .../0918_medium/circular_subarray_sum.py | 11 +++--- .../1359_hard/pickup_deliveries.cpp | 3 +- .../1359_hard/pickup_deliveries.py | 5 +-- .../1510_hard/perfect_stone_game.cpp | 3 +- .../1510_hard/perfect_stone_game.py | 9 ++--- .../1872_hard/merge_stone_game.cpp | 3 +- .../1872_hard/merge_stone_game.py | 3 +- .../0768_hard/max_chunks_prefix_version.cpp | 3 +- .../0768_hard/max_chunks_prefix_version.py | 7 +--- .../0768_hard/max_chunks_stack_version.cpp | 3 +- .../0768_hard/max_chunks_stack_version.py | 7 ++-- docs/greedy/2412_hard/min_required_money.cpp | 2 +- docs/greedy/2412_hard/min_required_money.py | 12 +++--- docs/hash/2963_hard/good_partitions.cpp | 3 +- docs/hash/2963_hard/good_partitions.py | 5 +-- docs/hash/3351_hard/good_subsequences_sum.cpp | 3 +- docs/hash/3351_hard/good_subsequences_sum.py | 19 ++++----- docs/heaps/0295_hard/median_finder.cpp | 3 +- docs/heaps/0295_hard/median_finder.py | 5 ++- docs/heaps/0767_medium/reorganized_string.cpp | 3 +- docs/heaps/0767_medium/reorganized_string.py | 8 ++-- .../prefix_sum/2025_hard/partitions_count.cpp | 3 +- docs/prefix_sum/2025_hard/partitions_count.py | 6 +-- docs/prefix_sum/2302_hard/subarray_scores.cpp | 3 +- docs/prefix_sum/2302_hard/subarray_scores.py | 3 +- docs/queue/0068_hard/text_justificator.cpp | 3 +- docs/queue/0068_hard/text_justificator.py | 7 ++-- docs/queue/2398_hard/max_robots.cpp | 3 +- docs/queue/2398_hard/max_robots.py | 11 ++++-- .../0076_hard/min_window_substring.cpp | 3 +- .../0076_hard/min_window_substring.py | 8 ++-- .../2444_hard/bounded_subarrays.cpp | 2 +- .../2444_hard/bounded_subarrays.py | 9 +++-- docs/stack/0895_hard/max_frequency_stack.cpp | 3 +- docs/stack/0895_hard/max_frequency_stack.py | 8 ++-- docs/stack/1944_hard/visible_people.cpp | 3 +- docs/stack/1944_hard/visible_people.py | 7 ++-- docs/stack/2296_hard/text_editor.cpp | 3 +- docs/stack/2296_hard/text_editor.py | 10 ++--- docs/stack/2454_hard/second_next_greater.cpp | 3 +- docs/stack/2454_hard/second_next_greater.py | 5 +-- .../3113_hard/max_boundary_subarrays.cpp | 2 +- .../stack/3113_hard/max_boundary_subarrays.py | 5 +-- .../stack/3430_hard/subarrays_max_min_sum.cpp | 3 +- docs/stack/3430_hard/subarrays_max_min_sum.py | 2 +- docs/two_pointers/1537_hard/max_score.cpp | 2 +- docs/two_pointers/1537_hard/max_score.py | 20 +++++----- .../1793_hard/good_subarray_score.cpp | 3 +- .../1793_hard/good_subarray_score.py | 5 +-- files_generators/problems_json_generator.py | 18 ++++++--- files_generators/sidebars_ts_generator.py | 23 +++++++---- .../1510_hard/perfect_stone_game.cpp | 3 +- .../1510_hard/perfect_stone_game.py | 9 ++--- .../3113_hard/max_boundary_subarrays.cpp | 2 +- .../stack/3113_hard/max_boundary_subarrays.py | 5 +-- .../two_pointers/1537_hard/max_score.cpp | 2 +- .../two_pointers/1537_hard/max_score.py | 20 +++++----- .../1793_hard/good_subarray_score.cpp | 3 +- .../1793_hard/good_subarray_score.py | 5 +-- package.json | 8 +++- 79 files changed, 294 insertions(+), 231 deletions(-) create mode 100644 .github/workflows/black-lint.yml create mode 100644 .github/workflows/clang-format-lint.yml diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml new file mode 100644 index 00000000..6fd6f4de --- /dev/null +++ b/.github/workflows/black-lint.yml @@ -0,0 +1,31 @@ +name: black-linter + +on: + push: + branches: [main, dev] + paths: + - docs/** + - i18n/** + - files_generators/** + - '*.py' + pull_request: + branches: [main] + paths: + - docs/** + - i18n/** + - files_generators/** + - '*.py' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: jpetrucciani/black-check@master + with: + black_flags: '-S' diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml new file mode 100644 index 00000000..dd931164 --- /dev/null +++ b/.github/workflows/clang-format-lint.yml @@ -0,0 +1,39 @@ +name: clang-format-linter + +on: + push: + branches: [main, dev] + paths: + - docs/** + - i18n/** + - '**.c' + - '**.cc' + - '**.cpp' + - '**.h' + - '**.hpp' + pull_request: + branches: [main] + paths: + - docs/** + - i18n/** + - '**.c' + - '**.cc' + - '**.cpp' + - '**.h' + - '**.hpp' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Run clang-format check + uses: jidicula/clang-format-action@v4.13.0 + with: + clang-format-version: '18' + check-path: '.' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c110a9ba..af337adb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,8 +2,9 @@ name: Deploy to GitHub Pages on: push: - branches: - - main + branches: [main, dev] + pull_request: + branches: [main] jobs: deploy: diff --git a/.gitignore b/.gitignore index d9cbcce9..a6e40ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,5 @@ yarn-debug.log* yarn-error.log* .idea - __MACOSX/ - __pycache__/ diff --git a/README.md b/README.md index 8a368a3f..f396aa08 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ # ๐Ÿ‡ๅคฉ็ ่กŒ็ฉบ ยท SkyHorse +[![main Deploy](https://github.com/StarsExpress/SkyHorse/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/StarsExpress/SkyHorse/actions) +[![main Black Linter](https://github.com/StarsExpress/SkyHorse/actions/workflows/black-lint.yml/badge.svg?branch=main)](https://github.com/StarsExpress/SkyHorse/actions) +[![main Clang Format Linter](https://github.com/StarsExpress/SkyHorse/actions/workflows/clang-format-lint.yml/badge.svg?branch=main)](https://github.com/StarsExpress/SkyHorse/actions) + ### [๐Ÿช‚ SkyHorse's History ๐Ÿ“š](https://starsexpress.github.io/Faraway-s-Way/skyhorse/) --- diff --git a/config.py b/config.py index 36c352a3..2199ef2f 100644 --- a/config.py +++ b/config.py @@ -7,11 +7,7 @@ DIFFICULTIES = ["easy", "medium", "hard"] -DIFF_ORDERS = dict( - zip( - DIFFICULTIES, range(1, len(DIFFICULTIES) + 1) - ) -) +DIFF_ORDERS = dict(zip(DIFFICULTIES, range(1, len(DIFFICULTIES) + 1))) # Topics with abbreviated prefix. diff --git a/docs/bfs/0987_hard/vertical_traversal.cpp b/docs/bfs/0987_hard/vertical_traversal.cpp index a89b8663..8ab2ae14 100644 --- a/docs/bfs/0987_hard/vertical_traversal.cpp +++ b/docs/bfs/0987_hard/vertical_traversal.cpp @@ -23,8 +23,7 @@ struct TreeNode { , right(right) {} }; -vector> findVerticalTraversal(TreeNode* root) // LeetCode Q.987. -{ +vector> findVerticalTraversal(TreeNode* root) { // Each tuple format: {tree node, row, column}. deque> queue = {{root, 0, 0}}; diff --git a/docs/bfs/0987_hard/vertical_traversal.py b/docs/bfs/0987_hard/vertical_traversal.py index 01547311..239e9a4e 100644 --- a/docs/bfs/0987_hard/vertical_traversal.py +++ b/docs/bfs/0987_hard/vertical_traversal.py @@ -8,7 +8,7 @@ def __init__(self, val=0, left=None, right=None) -> None: self.right = right -def find_vertical_traversal(root: TreeNode) -> list[list[int]]: # LeetCode Q.987. +def find_vertical_traversal(root: TreeNode) -> list[list[int]]: # Each tuple format: (tree node, row, column). queue: deque[tuple[TreeNode, int, int]] = deque([(root, 0, 0)]) diff --git a/docs/bfs/1466_medium/reordered_routes.cpp b/docs/bfs/1466_medium/reordered_routes.cpp index 5535b335..8d3de4b0 100644 --- a/docs/bfs/1466_medium/reordered_routes.cpp +++ b/docs/bfs/1466_medium/reordered_routes.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int find_min_reorders(int n, vector>& connections) // LeetCode Q.1466. -{ +int find_min_reorders(int n, vector>& connections) { vector> srcNodes(n, vector()), tgtNodes(n, vector()); vector visited(n, false); diff --git a/docs/bfs/1466_medium/reordered_routes.py b/docs/bfs/1466_medium/reordered_routes.py index 473a2d74..79cf10d9 100644 --- a/docs/bfs/1466_medium/reordered_routes.py +++ b/docs/bfs/1466_medium/reordered_routes.py @@ -1,7 +1,7 @@ from collections import deque -def find_min_reorders(n: int, connections: list[list[int]]) -> int: # LeetCode Q.1466. +def find_min_reorders(n: int, connections: list[list[int]]) -> int: src_nodes: list[list[int]] = [[] for _ in range(n)] # Each node's source nodes. tgt_nodes: list[list[int]] = [[] for _ in range(n)] # Each node's target nodes. diff --git a/docs/dfs/0329_hard/max_rising_path.cpp b/docs/dfs/0329_hard/max_rising_path.cpp index 732f102b..c5fdb412 100644 --- a/docs/dfs/0329_hard/max_rising_path.cpp +++ b/docs/dfs/0329_hard/max_rising_path.cpp @@ -2,8 +2,7 @@ #include using namespace std; -class MaxRisingPath // LeetCode Q.329. -{ +class MaxRisingPath { private: // An entry's max rising path value is -1 if this entry is unsearched. // Otherwise, max rising path value is the finalized value w.r.t. entry. diff --git a/docs/dfs/0329_hard/max_rising_path.py b/docs/dfs/0329_hard/max_rising_path.py index 1ea6a1af..43a71ae3 100644 --- a/docs/dfs/0329_hard/max_rising_path.py +++ b/docs/dfs/0329_hard/max_rising_path.py @@ -1,5 +1,4 @@ - -class MaxRisingPath: # LeetCode Q.329. +class MaxRisingPath: def __init__(self): self.matrix = [] self.max_rising_path = [] @@ -22,28 +21,39 @@ def find_longest_rising_path(self, matrix: list[list[int]]) -> int: return self.max_rising_len def _dfs_rising_path(self, row_idx: int, col_idx: int) -> None: - self.max_rising_path[row_idx][col_idx] = 1 # Base case: a path of only current entry. + # Base case: a path of only current entry. + self.max_rising_path[row_idx][col_idx] = 1 neighbors: list[tuple[int, int]] = [ - (row_idx + 1, col_idx), (row_idx - 1, col_idx), # South & North. - (row_idx, col_idx + 1), (row_idx, col_idx - 1) # East & West. + (row_idx + 1, col_idx), + (row_idx - 1, col_idx), # South & North. + (row_idx, col_idx + 1), + (row_idx, col_idx - 1), # East & West. ] for neighbor_row_idx, neighbor_col_idx in neighbors: # Inbound checks on row & col indices. - if not (0 <= neighbor_row_idx < len(self.matrix)): continue + if not (0 <= neighbor_row_idx < len(self.matrix)): + continue - if not (0 <= neighbor_col_idx < len(self.matrix[0])): continue + if not (0 <= neighbor_col_idx < len(self.matrix[0])): + continue # Only consider neighbors that are bigger than current entry. - if self.matrix[row_idx][col_idx] < self.matrix[neighbor_row_idx][neighbor_col_idx]: + if ( + self.matrix[row_idx][col_idx] + < self.matrix[neighbor_row_idx][neighbor_col_idx] + ): # Unsearched neighbor. if self.max_rising_path[neighbor_row_idx][neighbor_col_idx] == -1: self._dfs_rising_path(neighbor_row_idx, neighbor_col_idx) - rising_len = 1 + self.max_rising_path[neighbor_row_idx][neighbor_col_idx] + rising_len = ( + 1 + self.max_rising_path[neighbor_row_idx][neighbor_col_idx] + ) if rising_len > self.max_rising_path[row_idx][col_idx]: self.max_rising_path[row_idx][col_idx] = rising_len - if rising_len > self.max_rising_len: self.max_rising_len = rising_len + if rising_len > self.max_rising_len: + self.max_rising_len = rising_len diff --git a/docs/dfs/2360_hard/longest_cycle.cpp b/docs/dfs/2360_hard/longest_cycle.cpp index 34c7de2a..1478f543 100644 --- a/docs/dfs/2360_hard/longest_cycle.cpp +++ b/docs/dfs/2360_hard/longest_cycle.cpp @@ -1,8 +1,7 @@ #include using namespace std; -class LongestCycle // LeetCode Q.2360. -{ +class LongestCycle { private: vector graph, visitedOrders; int currentOrder = 1, maxCycle = -1; diff --git a/docs/dfs/2360_hard/longest_cycle.py b/docs/dfs/2360_hard/longest_cycle.py index 6f0cd0b4..2e77c96d 100644 --- a/docs/dfs/2360_hard/longest_cycle.py +++ b/docs/dfs/2360_hard/longest_cycle.py @@ -1,5 +1,4 @@ - -class LongestCycle: # LeetCode Q.2360. +class LongestCycle: def __init__(self): self.edges: list[int] = [] self.visited_orders: list[int] = [] diff --git a/docs/dfs/2876_hard/visited_nodes.cpp b/docs/dfs/2876_hard/visited_nodes.cpp index 61db7a58..2100d063 100644 --- a/docs/dfs/2876_hard/visited_nodes.cpp +++ b/docs/dfs/2876_hard/visited_nodes.cpp @@ -1,8 +1,7 @@ #include using namespace std; -class DirectedGraphVisitedNodes // LeetCode Q.2876. -{ +class DirectedGraphVisitedNodes { private: vector graph, visitedOrders, visitedCounts; int currentOrder = 1; diff --git a/docs/dfs/2876_hard/visited_nodes.py b/docs/dfs/2876_hard/visited_nodes.py index 29e62a50..db4b4edc 100644 --- a/docs/dfs/2876_hard/visited_nodes.py +++ b/docs/dfs/2876_hard/visited_nodes.py @@ -1,5 +1,4 @@ - -class DirectedGraphVisitedNodes: # LeetCode Q.2876. +class DirectedGraphVisitedNodes: def __init__(self): self.graph: list[int] = [] self.visited_orders: list[int] = [] @@ -18,7 +17,9 @@ def _dfs_visited_nodes(self, node: int) -> int: # A cycle just forms. Current node and its target node are members. if self.visited_orders[target_node] > 0: - cycle_size = self.visited_orders[node] + 1 - self.visited_orders[target_node] + cycle_size = self.visited_orders[node] + 1 + cycle_size -= self.visited_orders[target_node] + self.visited_counts[node] = cycle_size self.visited_orders[node] = -2 # Current node has finalized DFS. diff --git a/docs/dp_tabulation/0552_hard/student_attendance.cpp b/docs/dp_tabulation/0552_hard/student_attendance.cpp index 958b67dd..36e4dc2c 100644 --- a/docs/dp_tabulation/0552_hard/student_attendance.cpp +++ b/docs/dp_tabulation/0552_hard/student_attendance.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int countPossibilities(int recordLen) // LeetCode Q.552. -{ +int countPossibilities(int recordLen) { // Possible ends: "P", "L", "LL". long long noAbsEndP = 1, noAbsEndL = 1, noAbsEndLL = 0; diff --git a/docs/dp_tabulation/0552_hard/student_attendance.py b/docs/dp_tabulation/0552_hard/student_attendance.py index 812b2c64..ef4479a6 100644 --- a/docs/dp_tabulation/0552_hard/student_attendance.py +++ b/docs/dp_tabulation/0552_hard/student_attendance.py @@ -1,5 +1,4 @@ - -def count_possibilities(record_len: int) -> int: # LeetCode Q.552. +def count_possibilities(record_len: int) -> int: # Possible ends: "P", "L", "LL". Base case: record len = 1. no_abs_table = {"p": 1, "l": 1, "ll": 0} @@ -9,10 +8,10 @@ def count_possibilities(record_len: int) -> int: # LeetCode Q.552. # Help each day's tables update values. new_no_abs_table, new_one_abs_table = dict(), dict() - modulo = 10 ** 9 + 7 + modulo = 10**9 + 7 for _ in range(2, record_len + 1): - + no_abs_sum = sum(no_abs_table.values()) % modulo new_no_abs_table["p"] = no_abs_sum # No.1: all 0 absence ends are now "P". @@ -33,9 +32,9 @@ def count_possibilities(record_len: int) -> int: # LeetCode Q.552. no_abs_table.update(new_no_abs_table) one_abs_table.update(new_one_abs_table) - + new_no_abs_table.clear() # Reset for next day's usage. new_one_abs_table.clear() - + valid_combinations = sum(no_abs_table.values()) + sum(one_abs_table.values()) return valid_combinations % modulo diff --git a/docs/dp_tabulation/0918_medium/circular_subarray_sum.cpp b/docs/dp_tabulation/0918_medium/circular_subarray_sum.cpp index c5228dbf..f8928eab 100644 --- a/docs/dp_tabulation/0918_medium/circular_subarray_sum.cpp +++ b/docs/dp_tabulation/0918_medium/circular_subarray_sum.cpp @@ -1,7 +1,7 @@ #include using namespace std; -int computeMaxCircularSubarraySum(vector& nums) { // LeetCode Q.918. +int computeMaxCircularSubarraySum(vector& nums) { int arrayTotalSum = 0; int maxNum = nums.front(); diff --git a/docs/dp_tabulation/0918_medium/circular_subarray_sum.py b/docs/dp_tabulation/0918_medium/circular_subarray_sum.py index e45757c4..aac7a2bf 100644 --- a/docs/dp_tabulation/0918_medium/circular_subarray_sum.py +++ b/docs/dp_tabulation/0918_medium/circular_subarray_sum.py @@ -1,5 +1,4 @@ - -def compute_max_circular_subarray_sum(nums: list[int]) -> int: # LeetCode Q.918. +def compute_max_circular_subarray_sum(nums: list[int]) -> int: array_total_sum = 0 max_num = nums[0] @@ -8,7 +7,8 @@ def compute_max_circular_subarray_sum(nums: list[int]) -> int: # LeetCode Q.918 neg_subarray_sum, min_neg_sum = 0, 0 for num in nums: - if num > max_num: max_num = num + if num > max_num: + max_num = num array_total_sum += num @@ -18,7 +18,7 @@ def compute_max_circular_subarray_sum(nums: list[int]) -> int: # LeetCode Q.918 if pos_subarray_sum <= 0: # Positive sum <= 0: reset subarray. pos_subarray_sum = 0 - + neg_subarray_sum += num if neg_subarray_sum < min_neg_sum: min_neg_sum = neg_subarray_sum @@ -26,6 +26,7 @@ def compute_max_circular_subarray_sum(nums: list[int]) -> int: # LeetCode Q.918 if neg_subarray_sum >= 0: # Negative sum >= 0: reset subarray. neg_subarray_sum = 0 - if max_num <= 0: return max_num # All numbers are non-positive. + if max_num <= 0: + return max_num # All numbers are non-positive. return max(array_total_sum - min_neg_sum, max_pos_sum) diff --git a/docs/dp_tabulation/1359_hard/pickup_deliveries.cpp b/docs/dp_tabulation/1359_hard/pickup_deliveries.cpp index 01fa4a64..831f98c7 100644 --- a/docs/dp_tabulation/1359_hard/pickup_deliveries.cpp +++ b/docs/dp_tabulation/1359_hard/pickup_deliveries.cpp @@ -1,8 +1,7 @@ #include using namespace std; -int countValidSequences(int totalOrders) // LeetCode Q.1359. -{ +int countValidSequences(int totalOrders) { long long modulo = pow(10, 9) + 7; // Long long prevents overflow. // Base case when n is 1: pickup 1 followed by delivery 1. diff --git a/docs/dp_tabulation/1359_hard/pickup_deliveries.py b/docs/dp_tabulation/1359_hard/pickup_deliveries.py index e379ca0f..a294017e 100644 --- a/docs/dp_tabulation/1359_hard/pickup_deliveries.py +++ b/docs/dp_tabulation/1359_hard/pickup_deliveries.py @@ -1,6 +1,5 @@ - -def count_valid_sequences(total_orders: int) -> int: # LeetCode Q.1359. - modulo = 10 ** 9 + 7 +def count_valid_sequences(total_orders: int) -> int: + modulo = 10**9 + 7 # Base case when n is 1: pickup 1 followed by delivery 1. valid_sequences = 1 diff --git a/docs/dp_tabulation/1510_hard/perfect_stone_game.cpp b/docs/dp_tabulation/1510_hard/perfect_stone_game.cpp index d31e2e80..c469e5e7 100644 --- a/docs/dp_tabulation/1510_hard/perfect_stone_game.cpp +++ b/docs/dp_tabulation/1510_hard/perfect_stone_game.cpp @@ -1,8 +1,7 @@ #include using namespace std; -bool judgeWinnability(int stonesCount) // LeetCode Q.1510. -{ +bool judgeWinnability(int stonesCount) { vector squaresCounts(stonesCount + 1, 0); for (int num = 1; num <= stonesCount; num++) { diff --git a/docs/dp_tabulation/1510_hard/perfect_stone_game.py b/docs/dp_tabulation/1510_hard/perfect_stone_game.py index cfe318a0..95d8b3f1 100644 --- a/docs/dp_tabulation/1510_hard/perfect_stone_game.py +++ b/docs/dp_tabulation/1510_hard/perfect_stone_game.py @@ -1,15 +1,14 @@ - -def judge_winnability(stones_count: int) -> bool: # LeetCode Q.1510. +def judge_winnability(stones_count: int) -> bool: squares_counts = [0] * (stones_count + 1) for num in range(1, stones_count + 1): - max_sqrt = int(num ** 0.5) - if max_sqrt ** 2 == num: + max_sqrt = int(num**0.5) + if max_sqrt**2 == num: squares_counts[num] += 1 # From 0 to 1. continue for sqrt in range(max_sqrt, 0, -1): - residual = num - (sqrt ** 2) + residual = num - (sqrt**2) if squares_counts[residual] == 0: squares_counts[num] += 1 # From 0 to 1. break diff --git a/docs/dp_tabulation/1872_hard/merge_stone_game.cpp b/docs/dp_tabulation/1872_hard/merge_stone_game.cpp index 2f763167..7711dc4e 100644 --- a/docs/dp_tabulation/1872_hard/merge_stone_game.cpp +++ b/docs/dp_tabulation/1872_hard/merge_stone_game.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int maximizeScoresDifference(vector& stones) // LeetCode Q.1872. -{ +int maximizeScoresDifference(vector& stones) { int prefixSum = 0; for (const auto& stone : stones) prefixSum += stone; diff --git a/docs/dp_tabulation/1872_hard/merge_stone_game.py b/docs/dp_tabulation/1872_hard/merge_stone_game.py index 83e90b3b..8e093d61 100644 --- a/docs/dp_tabulation/1872_hard/merge_stone_game.py +++ b/docs/dp_tabulation/1872_hard/merge_stone_game.py @@ -1,5 +1,4 @@ - -def maximize_scores_difference(stones: list[int]) -> int: # LeetCode Q.1872. +def maximize_scores_difference(stones: list[int]) -> int: prefix_sum = sum(stones) # Base case: Alice merges everything as the only attempt. diff --git a/docs/greedy/0768_hard/max_chunks_prefix_version.cpp b/docs/greedy/0768_hard/max_chunks_prefix_version.cpp index 10ea791b..ae3dcfa3 100644 --- a/docs/greedy/0768_hard/max_chunks_prefix_version.cpp +++ b/docs/greedy/0768_hard/max_chunks_prefix_version.cpp @@ -1,8 +1,7 @@ #include using namespace std; -int findMaxSortableChunks(vector& nums) // LeetCode Q.768 & 769. -{ +int findMaxSortableChunks(vector& nums) { vector prefixMaxs; // Max of each nums[:(i + 1)th idx]. for (const auto& num : nums) { diff --git a/docs/greedy/0768_hard/max_chunks_prefix_version.py b/docs/greedy/0768_hard/max_chunks_prefix_version.py index d4837c03..3f8f81fe 100644 --- a/docs/greedy/0768_hard/max_chunks_prefix_version.py +++ b/docs/greedy/0768_hard/max_chunks_prefix_version.py @@ -1,5 +1,4 @@ - -def find_max_sortable_chunks(nums: list[int]) -> int: # LeetCode Q.768 & 769. +def find_max_sortable_chunks(nums: list[int]) -> int: prefix_maxs = [] # Max of each nums[:(i + 1)th idx]. for num in nums: @@ -7,9 +6,7 @@ def find_max_sortable_chunks(nums: list[int]) -> int: # LeetCode Q.768 & 769. prefix_maxs.append(num) continue - prefix_maxs.append( - max(num, prefix_maxs[-1]) - ) + prefix_maxs.append(max(num, prefix_maxs[-1])) max_chunks = 1 # Base case. suffix_min = nums[-1] # Min of nums[ith idx:]. diff --git a/docs/greedy/0768_hard/max_chunks_stack_version.cpp b/docs/greedy/0768_hard/max_chunks_stack_version.cpp index dbe375cc..f3502663 100644 --- a/docs/greedy/0768_hard/max_chunks_stack_version.cpp +++ b/docs/greedy/0768_hard/max_chunks_stack_version.cpp @@ -2,8 +2,7 @@ using namespace std; #include -int findMaxSortableChunks(vector& nums) // LeetCode Q.768 & 769. -{ +int findMaxSortableChunks(vector& nums) { stack stack; for (const auto& num : nums) { diff --git a/docs/greedy/0768_hard/max_chunks_stack_version.py b/docs/greedy/0768_hard/max_chunks_stack_version.py index 40bef749..20d42656 100644 --- a/docs/greedy/0768_hard/max_chunks_stack_version.py +++ b/docs/greedy/0768_hard/max_chunks_stack_version.py @@ -1,5 +1,4 @@ - -def find_max_sortable_chunks(nums: list[int]) -> int: # LeetCode Q.768 & 769. +def find_max_sortable_chunks(nums: list[int]) -> int: stack: list[int] = [] for num in nums: @@ -8,10 +7,10 @@ def find_max_sortable_chunks(nums: list[int]) -> int: # LeetCode Q.768 & 769. continue chunk_max = stack[-1] - + while stack and stack[-1] > num: stack.pop(-1) - + stack.append(max(chunk_max, num)) return len(stack) diff --git a/docs/greedy/2412_hard/min_required_money.cpp b/docs/greedy/2412_hard/min_required_money.cpp index 26775d4b..a55b4f39 100644 --- a/docs/greedy/2412_hard/min_required_money.cpp +++ b/docs/greedy/2412_hard/min_required_money.cpp @@ -1,7 +1,7 @@ #include using namespace std; -long long calculateMinRequiredMoney(vector>& transactions) { // LeetCode Q.2412. +long long calculateMinRequiredMoney(vector>& transactions) { long long totalAbsLoss = 0; int winningTradeMaxCost = -1; diff --git a/docs/greedy/2412_hard/min_required_money.py b/docs/greedy/2412_hard/min_required_money.py index 240a03aa..e28878c7 100644 --- a/docs/greedy/2412_hard/min_required_money.py +++ b/docs/greedy/2412_hard/min_required_money.py @@ -1,5 +1,4 @@ - -def calculate_min_required_money(transactions: list[list[int]]) -> int: # LeetCode Q.2412. +def calculate_min_required_money(transactions: list[list[int]]) -> int: total_abs_loss = 0 losing_trade_max_cashback = -1 @@ -13,13 +12,14 @@ def calculate_min_required_money(transactions: list[list[int]]) -> int: # LeetC abs_loss = cost - cashback total_abs_loss += abs_loss - + if cashback > losing_trade_max_cashback: losing_trade_max_cashback = cashback - + min_required_money = total_abs_loss + losing_trade_max_cashback - - if winning_trade_max_cost == -1: return min_required_money + + if winning_trade_max_cost == -1: + return min_required_money if min_required_money < winning_trade_max_cost + total_abs_loss: min_required_money = winning_trade_max_cost + total_abs_loss diff --git a/docs/hash/2963_hard/good_partitions.cpp b/docs/hash/2963_hard/good_partitions.cpp index 169e8fae..6d15a739 100644 --- a/docs/hash/2963_hard/good_partitions.cpp +++ b/docs/hash/2963_hard/good_partitions.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int countGoodPartitions(vector& nums) // LeetCode Q.2963. -{ +int countGoodPartitions(vector& nums) { unordered_map numsLastIndices; // Each num's last idx. for (int idx = 0; idx < nums.size(); idx++) diff --git a/docs/hash/2963_hard/good_partitions.py b/docs/hash/2963_hard/good_partitions.py index 6c08da3b..a1fe253a 100644 --- a/docs/hash/2963_hard/good_partitions.py +++ b/docs/hash/2963_hard/good_partitions.py @@ -1,5 +1,4 @@ - -def count_good_partitions(nums: list[int]) -> int: # LeetCode Q.2963. +def count_good_partitions(nums: list[int]) -> int: nums_last_indices: dict[int, int] = dict() # Each num's last idx. for idx, num in enumerate(nums): @@ -24,7 +23,7 @@ def count_good_partitions(nums: list[int]) -> int: # LeetCode Q.2963. good_partitions = 1 power = windows_count - 1 base = 2 # Mod exp method speeds up quite some in Python. - modulo = 10 ** 9 + 7 + modulo = 10**9 + 7 while power > 0: if power % 2 == 1: # Power is odd: product times current base. diff --git a/docs/hash/3351_hard/good_subsequences_sum.cpp b/docs/hash/3351_hard/good_subsequences_sum.cpp index ea4bbdc8..2c1e345a 100644 --- a/docs/hash/3351_hard/good_subsequences_sum.cpp +++ b/docs/hash/3351_hard/good_subsequences_sum.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int sumGoodSubsequences(vector& nums) // LeetCode Q.3351. -{ +int sumGoodSubsequences(vector& nums) { long long modulo = pow(10, 9) + 7; // Long long prevents overflow. unordered_map subseqCounts, subseqSums; diff --git a/docs/hash/3351_hard/good_subsequences_sum.py b/docs/hash/3351_hard/good_subsequences_sum.py index 148adfe8..ed65e2d0 100644 --- a/docs/hash/3351_hard/good_subsequences_sum.py +++ b/docs/hash/3351_hard/good_subsequences_sum.py @@ -1,16 +1,11 @@ - -def sum_good_subsequences(nums: list[int]) -> int: # LeetCode Q.3351. - modulo = 10 ** 9 + 7 # Prevents overflow. +def sum_good_subsequences(nums: list[int]) -> int: + modulo = 10**9 + 7 # Prevents overflow. unique_nums = set(nums) - subseqCounts: dict[int, int] = dict( - zip(unique_nums, [0] * len(unique_nums)) - ) + subseqCounts: dict[int, int] = dict(zip(unique_nums, [0] * len(unique_nums))) - subseqSums: dict[int, int] = dict( - zip(unique_nums, [0] * len(unique_nums)) - ) + subseqSums: dict[int, int] = dict(zip(unique_nums, [0] * len(unique_nums))) for num in nums: for validTail in (num - 1, num + 1): @@ -22,9 +17,11 @@ def sum_good_subsequences(nums: list[int]) -> int: # LeetCode Q.3351. # Counts & sums are O(2^n) so must do modulo for future operations. subseqCounts[num] += 1 - if subseqCounts[num] > modulo: subseqCounts[num] %= modulo + if subseqCounts[num] > modulo: + subseqCounts[num] %= modulo subseqSums[num] += num - if subseqSums[num] > modulo: subseqSums[num] %= modulo + if subseqSums[num] > modulo: + subseqSums[num] %= modulo return sum(subseqSums.values()) % modulo # Control value magnitude. diff --git a/docs/heaps/0295_hard/median_finder.cpp b/docs/heaps/0295_hard/median_finder.cpp index 54ec4096..da85f9e4 100644 --- a/docs/heaps/0295_hard/median_finder.cpp +++ b/docs/heaps/0295_hard/median_finder.cpp @@ -1,8 +1,7 @@ #include using namespace std; -class MedianFinder // LeetCode Q.295. -{ +class MedianFinder { private: // When nums count is odd, median goes to min heap. // Min heap needs to negate value to fit default C++ max heap. diff --git a/docs/heaps/0295_hard/median_finder.py b/docs/heaps/0295_hard/median_finder.py index 06b8ec03..c0d903a8 100644 --- a/docs/heaps/0295_hard/median_finder.py +++ b/docs/heaps/0295_hard/median_finder.py @@ -1,7 +1,7 @@ import heapq -class MedianFinder: # LeetCode Q.295. +class MedianFinder: def __init__(self): # When nums count is odd, median goes to min heap. # Max heap needs to negate value to fit default Python min heap. @@ -16,7 +16,8 @@ def add_num(self, num: int) -> None: heapq.heappush(self.max_heap, -num) # Max heap negates. while self.max_heap and self.min_heap: - if -self.max_heap[0] <= self.min_heap[0]: break # No need to adjust. + if -self.max_heap[0] <= self.min_heap[0]: + break # No need to adjust. # -Max heap top > min heap top: mismatch so must switch. former_max_heap_top = -heapq.heappop(self.max_heap) # Max heap negates. diff --git a/docs/heaps/0767_medium/reorganized_string.cpp b/docs/heaps/0767_medium/reorganized_string.cpp index 3eaa4002..a0b31ccb 100644 --- a/docs/heaps/0767_medium/reorganized_string.cpp +++ b/docs/heaps/0767_medium/reorganized_string.cpp @@ -3,8 +3,7 @@ #include using namespace std; -string reorganizeString(string initString) // LeetCode Q.767. -{ +string reorganizeString(string initString) { unordered_map charsCounts; for (const char& character : initString) { diff --git a/docs/heaps/0767_medium/reorganized_string.py b/docs/heaps/0767_medium/reorganized_string.py index a4f3ef67..57c270c4 100644 --- a/docs/heaps/0767_medium/reorganized_string.py +++ b/docs/heaps/0767_medium/reorganized_string.py @@ -1,7 +1,7 @@ import heapq -def reorganize_string(init_string: str) -> str: # LeetCode Q.767. +def reorganize_string(init_string: str) -> str: chars_counts: dict[str, int] = dict() for char in init_string: @@ -10,7 +10,8 @@ def reorganize_string(init_string: str) -> str: # LeetCode Q.767. chars_counts[char] += 1 # Sanity check. - if chars_counts[char] > (len(init_string) + 1) / 2: return "" + if chars_counts[char] > (len(init_string) + 1) / 2: + return "" max_heap: list[tuple[int, str]] = [] # Format: (count, char). @@ -34,6 +35,7 @@ def reorganize_string(init_string: str) -> str: # LeetCode Q.767. if top_2_count > 1: # Negate count to fit max heap. heapq.heappush(max_heap, (1 - top_2_count, top_2_char)) - if max_heap: reshaped_string += max_heap[-1][1] + if max_heap: + reshaped_string += max_heap[-1][1] return reshaped_string diff --git a/docs/prefix_sum/2025_hard/partitions_count.cpp b/docs/prefix_sum/2025_hard/partitions_count.cpp index d03ae89a..30ab38f9 100644 --- a/docs/prefix_sum/2025_hard/partitions_count.cpp +++ b/docs/prefix_sum/2025_hard/partitions_count.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int countMaxPartitions(vector& nums, int k) // LeetCode Q.2025. -{ +int countMaxPartitions(vector& nums, int k) { long long totalSum = 0; // Prevents overflow. for (const auto& num : nums) totalSum += num; diff --git a/docs/prefix_sum/2025_hard/partitions_count.py b/docs/prefix_sum/2025_hard/partitions_count.py index ba420d70..55c93b53 100644 --- a/docs/prefix_sum/2025_hard/partitions_count.py +++ b/docs/prefix_sum/2025_hard/partitions_count.py @@ -1,5 +1,4 @@ - -def count_max_partitions(nums: list[int], k: int) -> int: # LeetCode Q.2025. +def count_max_partitions(nums: list[int], k: int) -> int: # Left diff: only consider potential pivot indices at left side. # Right diff: only consider potential pivot indices at right side. # Dict key: diff = prefix sum - suffix sum. @@ -23,7 +22,8 @@ def count_max_partitions(nums: list[int], k: int) -> int: # LeetCode Q.2025. right_diff_counts[diff] += 1 # Born as a great partition. No need to change. - if prefix_sum == suffix_sum: max_partition_ways += 1 + if prefix_sum == suffix_sum: + max_partition_ways += 1 prefix_sum = 0 # Reset to let next for loop sweep again. diff --git a/docs/prefix_sum/2302_hard/subarray_scores.cpp b/docs/prefix_sum/2302_hard/subarray_scores.cpp index ac867523..9b13c654 100644 --- a/docs/prefix_sum/2302_hard/subarray_scores.cpp +++ b/docs/prefix_sum/2302_hard/subarray_scores.cpp @@ -1,8 +1,7 @@ #include using namespace std; -long long countSubarrayScores(vector& nums, long long k) // LeetCode Q.2302. -{ +long long countSubarrayScores(vector& nums, long long k) { long long lessThanKSubarraysCount = 0; // Long long prevents overflow. long long subarraySum = 0; // Long long prevents overflow. diff --git a/docs/prefix_sum/2302_hard/subarray_scores.py b/docs/prefix_sum/2302_hard/subarray_scores.py index 66588c22..6aa64a60 100644 --- a/docs/prefix_sum/2302_hard/subarray_scores.py +++ b/docs/prefix_sum/2302_hard/subarray_scores.py @@ -1,5 +1,4 @@ - -def count_subarray_scores(nums: list[int], k: int) -> int: # LeetCode Q.2302. +def count_subarray_scores(nums: list[int], k: int) -> int: total_subarrays = 0 subarray_sum = 0 diff --git a/docs/queue/0068_hard/text_justificator.cpp b/docs/queue/0068_hard/text_justificator.cpp index f8375445..78310c13 100644 --- a/docs/queue/0068_hard/text_justificator.cpp +++ b/docs/queue/0068_hard/text_justificator.cpp @@ -3,8 +3,7 @@ #include using namespace std; -class TextJustificator // LeetCode Q.68. -{ +class TextJustificator { private: deque queue; diff --git a/docs/queue/0068_hard/text_justificator.py b/docs/queue/0068_hard/text_justificator.py index 30a95082..11427af7 100644 --- a/docs/queue/0068_hard/text_justificator.py +++ b/docs/queue/0068_hard/text_justificator.py @@ -1,9 +1,10 @@ - -class TextJustificator: # LeetCode Q.68. +class TextJustificator: def __init__(self) -> None: self.queue: list[str] = [] - def _form_sentence(self, chars_count: int, max_width: int, left_justify: bool) -> str: + def _form_sentence( + self, chars_count: int, max_width: int, left_justify: bool + ) -> str: interval_spaces = "" intervals_count = len(self.queue) - 1 modulo = 0 diff --git a/docs/queue/2398_hard/max_robots.cpp b/docs/queue/2398_hard/max_robots.cpp index d6b656b4..d19c56bd 100644 --- a/docs/queue/2398_hard/max_robots.cpp +++ b/docs/queue/2398_hard/max_robots.cpp @@ -2,8 +2,7 @@ #include using namespace std; -int countMaxRobots(vector& chargeTimes, vector& runningCosts, long long budget) // LeetCode Q.2398. -{ +int countMaxRobots(vector& chargeTimes, vector& runningCosts, long long budget) { int maxRobotsCount = 0; // Base case. long long windowTotalCost = 0; diff --git a/docs/queue/2398_hard/max_robots.py b/docs/queue/2398_hard/max_robots.py index e930e72b..40fc98ad 100644 --- a/docs/queue/2398_hard/max_robots.py +++ b/docs/queue/2398_hard/max_robots.py @@ -1,7 +1,7 @@ from collections import deque -def count_max_robots(charge_times: list[int], running_costs: list[int], budget: int): # LeetCode Q.2398. +def count_max_robots(charge_times: list[int], running_costs: list[int], budget: int): max_robots_count = 0 # Base case. window_total_cost = 0 @@ -26,10 +26,13 @@ def count_max_robots(charge_times: list[int], running_costs: list[int], budget: robots_count -= 1 start_idx += 1 - if queue and queue[0][1] < start_idx: queue.popleft() + if queue and queue[0][1] < start_idx: + queue.popleft() - if start_idx > end_idx: break # 0 robots at hand. + if start_idx > end_idx: + break # 0 robots at hand. - if robots_count > max_robots_count: max_robots_count = robots_count + if robots_count > max_robots_count: + max_robots_count = robots_count return max_robots_count diff --git a/docs/sliding_window/0076_hard/min_window_substring.cpp b/docs/sliding_window/0076_hard/min_window_substring.cpp index 1ab192f1..7af016d2 100644 --- a/docs/sliding_window/0076_hard/min_window_substring.cpp +++ b/docs/sliding_window/0076_hard/min_window_substring.cpp @@ -2,8 +2,7 @@ #include using namespace std; -string findMinWindowSubstring(string sourceString, string targetString) // LeetCode Q.76. -{ +string findMinWindowSubstring(string sourceString, string targetString) { unordered_map tgtCharsCounts; for (const auto& character : targetString) diff --git a/docs/sliding_window/0076_hard/min_window_substring.py b/docs/sliding_window/0076_hard/min_window_substring.py index 04407176..5145c280 100644 --- a/docs/sliding_window/0076_hard/min_window_substring.py +++ b/docs/sliding_window/0076_hard/min_window_substring.py @@ -1,5 +1,4 @@ - -def find_min_window_substring(source_str: str, target_str: str) -> str: # LeetCode Q.76. +def find_min_window_substring(source_str: str, target_str: str) -> str: tgt_chars_counts: dict[str, int] = dict() for char in target_str: @@ -39,6 +38,7 @@ def find_min_window_substring(source_str: str, target_str: str) -> str: # LeetC left_idx += 1 - if min_len == len(source_str) + 1: return "" + if min_len == len(source_str) + 1: + return "" - return source_str[min_window_left_idx: min_window_left_idx + min_len] + return source_str[min_window_left_idx : min_window_left_idx + min_len] diff --git a/docs/sliding_window/2444_hard/bounded_subarrays.cpp b/docs/sliding_window/2444_hard/bounded_subarrays.cpp index aa38eaf2..d3705e64 100644 --- a/docs/sliding_window/2444_hard/bounded_subarrays.cpp +++ b/docs/sliding_window/2444_hard/bounded_subarrays.cpp @@ -1,7 +1,7 @@ #include using namespace std; -long long countBoundedSubarrays(vector& nums, int minK, int maxK) { // LeetCode Q.2444. +long long countBoundedSubarrays(vector& nums, int minK, int maxK) { long long boundedSubarraysCount = 0; int prevMinIdx = -1, prevMaxIdx = -1; diff --git a/docs/sliding_window/2444_hard/bounded_subarrays.py b/docs/sliding_window/2444_hard/bounded_subarrays.py index 82f93d92..3623aea9 100644 --- a/docs/sliding_window/2444_hard/bounded_subarrays.py +++ b/docs/sliding_window/2444_hard/bounded_subarrays.py @@ -1,5 +1,4 @@ - -def count_bounded_subarrays(nums: list[int], min_k: int, max_k: int): # LeetCode Q.2444. +def count_bounded_subarrays(nums: list[int], min_k: int, max_k: int): bounded_subarrays_count = 0 prev_min_idx, prev_max_idx = -1, -1 @@ -11,8 +10,10 @@ def count_bounded_subarrays(nums: list[int], min_k: int, max_k: int): # LeetCod left_idx = right_idx + 1 continue - if num == max_k: prev_max_idx = right_idx - if num == min_k: prev_min_idx = right_idx + if num == max_k: + prev_max_idx = right_idx + if num == min_k: + prev_min_idx = right_idx if min(prev_min_idx, prev_max_idx) >= 0: bounded_subarrays_count += min(prev_min_idx, prev_max_idx) + 1 - left_idx diff --git a/docs/stack/0895_hard/max_frequency_stack.cpp b/docs/stack/0895_hard/max_frequency_stack.cpp index 7e93c2c8..421abca7 100644 --- a/docs/stack/0895_hard/max_frequency_stack.cpp +++ b/docs/stack/0895_hard/max_frequency_stack.cpp @@ -3,8 +3,7 @@ #include using namespace std; -class MaxFrequencyStack // LeetCode Q.895. -{ +class MaxFrequencyStack { private: // Each idx contains stack of values with frequency = idx. // Pad empty stack to adjust for 0-based indexing. diff --git a/docs/stack/0895_hard/max_frequency_stack.py b/docs/stack/0895_hard/max_frequency_stack.py index fff6b00a..ee69c841 100644 --- a/docs/stack/0895_hard/max_frequency_stack.py +++ b/docs/stack/0895_hard/max_frequency_stack.py @@ -1,12 +1,11 @@ - -class MaxFrequencyStack: # LeetCode Q.895. +class MaxFrequencyStack: def __init__(self): self.vals_freqs: dict[int, int] = dict() # Each idx contains stack of values w/ frequency = idx. # Pad empty stack to adjust for 0-based indexing. self.freqs_stacks: list[list[int]] = [[]] - + def push(self, value: int) -> None: if value not in self.vals_freqs.keys(): self.vals_freqs.update({value: 0}) @@ -22,7 +21,8 @@ def push(self, value: int) -> None: def pop(self) -> int: most_freq_val = self.freqs_stacks[-1].pop(-1) - if not self.freqs_stacks[-1]: self.freqs_stacks.pop(-1) + if not self.freqs_stacks[-1]: + self.freqs_stacks.pop(-1) self.vals_freqs[most_freq_val] -= 1 return most_freq_val diff --git a/docs/stack/1944_hard/visible_people.cpp b/docs/stack/1944_hard/visible_people.cpp index f60fdd09..a1a7d147 100644 --- a/docs/stack/1944_hard/visible_people.cpp +++ b/docs/stack/1944_hard/visible_people.cpp @@ -2,8 +2,7 @@ #include using namespace std; -vector countVisibilities(vector& heights) // LeetCode Q.1944. -{ +vector countVisibilities(vector& heights) { stack stack; // A stack of heights. vector visibilities(heights.size(), 0); diff --git a/docs/stack/1944_hard/visible_people.py b/docs/stack/1944_hard/visible_people.py index 77214328..35cc5da4 100644 --- a/docs/stack/1944_hard/visible_people.py +++ b/docs/stack/1944_hard/visible_people.py @@ -1,11 +1,10 @@ - -def count_visibilities(heights: list[int]) -> list[int]: # LeetCode Q.1944. +def count_visibilities(heights: list[int]) -> list[int]: stack = [] visibilities = [0] * len(heights) for idx in range(len(heights) - 1, -1, -1): # Backward iteration. height = heights[idx] - + while stack and stack[-1] < height: # People on my left side can't see them. stack.pop(-1) visibilities[idx] += 1 # I can see unblocked shorter people. @@ -15,7 +14,7 @@ def count_visibilities(heights: list[int]) -> list[int]: # LeetCode Q.1944. if stack[-1] == height: # People on my left side can't see this person. stack.pop(-1) - + stack.append(height) return visibilities diff --git a/docs/stack/2296_hard/text_editor.cpp b/docs/stack/2296_hard/text_editor.cpp index 29b8b1bf..2d8b09fa 100644 --- a/docs/stack/2296_hard/text_editor.cpp +++ b/docs/stack/2296_hard/text_editor.cpp @@ -3,8 +3,7 @@ #include using namespace std; -class TextEditor // LeetCode Q.2296. -{ +class TextEditor { private: deque cursorLeftSide, cursorRightSide; diff --git a/docs/stack/2296_hard/text_editor.py b/docs/stack/2296_hard/text_editor.py index e5d0aaa5..ac7839ea 100644 --- a/docs/stack/2296_hard/text_editor.py +++ b/docs/stack/2296_hard/text_editor.py @@ -1,12 +1,12 @@ from collections import deque -class TextEditor: # LeetCode Q.2296. +class TextEditor: def __init__(self) -> None: self.cursor_left_side: deque[str] = deque([]) self.cursor_right_side: deque[str] = deque([]) - def _slice_cursor_left_tail(self) -> str: + def _slice_cursor_left_tail(self) -> str: start_idx = max(0, len(self.cursor_left_side) - 10) text = "" @@ -24,7 +24,7 @@ def delete_text(self, k: int) -> int: while k > 0 and self.cursor_left_side: self.cursor_left_side.pop() k -= 1 - + return deletions_count def cursor_left(self, k: int) -> str: @@ -32,7 +32,7 @@ def cursor_left(self, k: int) -> str: char = self.cursor_left_side.pop() self.cursor_right_side.appendleft(char) k -= 1 - + return self._slice_cursor_left_tail() def cursor_right(self, k: int) -> str: @@ -40,5 +40,5 @@ def cursor_right(self, k: int) -> str: char = self.cursor_right_side.popleft() self.cursor_left_side.append(char) k -= 1 - + return self._slice_cursor_left_tail() diff --git a/docs/stack/2454_hard/second_next_greater.cpp b/docs/stack/2454_hard/second_next_greater.cpp index d2afad18..5a9347e0 100644 --- a/docs/stack/2454_hard/second_next_greater.cpp +++ b/docs/stack/2454_hard/second_next_greater.cpp @@ -2,8 +2,7 @@ #include using namespace std; -vector find_second_next_greater(vector& nums) // LeetCode Q.2454. -{ +vector find_second_next_greater(vector& nums) { vector secondNextGreater(nums.size(), -1); // Decreasing monotonic stacks: {num, idx}. diff --git a/docs/stack/2454_hard/second_next_greater.py b/docs/stack/2454_hard/second_next_greater.py index 16e33f69..36612f3b 100644 --- a/docs/stack/2454_hard/second_next_greater.py +++ b/docs/stack/2454_hard/second_next_greater.py @@ -1,5 +1,4 @@ - -def find_second_next_greater(nums: list[int]) -> list[int]: # LeetCode Q.2454. +def find_second_next_greater(nums: list[int]) -> list[int]: second_next_greater = [-1] * len(nums) stack_1: list[tuple[int, int]] = [] # Decreasing monotonic stacks: (num, idx). @@ -14,7 +13,7 @@ def find_second_next_greater(nums: list[int]) -> list[int]: # LeetCode Q.2454. while stack_1 and stack_1[-1][0] < num: transporter.append(stack_1.pop(-1)) - + while transporter: stack_2.append(transporter.pop(-1)) # Ensure decreasing monotonicity. stack_1.append((num, idx)) diff --git a/docs/stack/3113_hard/max_boundary_subarrays.cpp b/docs/stack/3113_hard/max_boundary_subarrays.cpp index 121fe0d6..57d6b813 100644 --- a/docs/stack/3113_hard/max_boundary_subarrays.cpp +++ b/docs/stack/3113_hard/max_boundary_subarrays.cpp @@ -2,7 +2,7 @@ #include using namespace std; -long long count_subarrays(vector& nums) { // LeetCode Q.3113. +long long count_subarrays(vector& nums) { stack> stack; // Format: {num, count}. long long subarraysCount = 0; diff --git a/docs/stack/3113_hard/max_boundary_subarrays.py b/docs/stack/3113_hard/max_boundary_subarrays.py index 9edeca69..7724aba3 100644 --- a/docs/stack/3113_hard/max_boundary_subarrays.py +++ b/docs/stack/3113_hard/max_boundary_subarrays.py @@ -1,5 +1,4 @@ - -def count_subarrays(nums: list[int]) -> int: # LeetCode Q.3113. +def count_subarrays(nums: list[int]) -> int: stack: list[tuple[int, int]] = [] # Format: (num, count). subarrays_count = 0 @@ -7,7 +6,7 @@ def count_subarrays(nums: list[int]) -> int: # LeetCode Q.3113. for num in nums: while stack and stack[-1][0] < num: stack.pop(-1) - + count = 1 # Base case: current num only. if stack and stack[-1][0] == num: diff --git a/docs/stack/3430_hard/subarrays_max_min_sum.cpp b/docs/stack/3430_hard/subarrays_max_min_sum.cpp index f8f40d44..94c37d46 100644 --- a/docs/stack/3430_hard/subarrays_max_min_sum.cpp +++ b/docs/stack/3430_hard/subarrays_max_min_sum.cpp @@ -2,8 +2,7 @@ #include using namespace std; -long long computeMaxMinSum(vector& nums, int k) // LeetCode Q.3430. -{ +long long computeMaxMinSum(vector& nums, int k) { long long totalMaxMinSum = 0; long long windowMaxSum = 0, windowMinSum = 0; diff --git a/docs/stack/3430_hard/subarrays_max_min_sum.py b/docs/stack/3430_hard/subarrays_max_min_sum.py index b572a3a8..e88d1f2d 100644 --- a/docs/stack/3430_hard/subarrays_max_min_sum.py +++ b/docs/stack/3430_hard/subarrays_max_min_sum.py @@ -1,7 +1,7 @@ from collections import deque -def compute_max_min_sum(nums: list[int], k: int) -> int: # LeetCode Q.3430. +def compute_max_min_sum(nums: list[int], k: int) -> int: subarrays_max_min_sum = 0 max_stack: deque[list[int]] = deque([]) # Format: [idx, num, shares]. diff --git a/docs/two_pointers/1537_hard/max_score.cpp b/docs/two_pointers/1537_hard/max_score.cpp index a9aa3496..b9ebb912 100644 --- a/docs/two_pointers/1537_hard/max_score.cpp +++ b/docs/two_pointers/1537_hard/max_score.cpp @@ -2,7 +2,7 @@ #include using namespace std; -int findMaxScore(vector& nums1, vector& nums2) { // LeetCode Q.1537. +int findMaxScore(vector& nums1, vector& nums2) { long long maxScore = 0; // Must use long long to prevent overflow. long long scoreOne = 0, scoreTwo = 0; diff --git a/docs/two_pointers/1537_hard/max_score.py b/docs/two_pointers/1537_hard/max_score.py index 666b3d9d..0ac46863 100644 --- a/docs/two_pointers/1537_hard/max_score.py +++ b/docs/two_pointers/1537_hard/max_score.py @@ -1,7 +1,6 @@ - -def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: # LeetCode Q.1537. +def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: max_score = 0 - modulo = 10 ** 9 + 7 + modulo = 10**9 + 7 score_1, score_2 = 0, 0 @@ -11,22 +10,25 @@ def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: # LeetCode Q.1 while idx_1 < len(nums_1) and nums_1[idx_1] < nums_2[idx_2]: score_1 += nums_1[idx_1] idx_1 += 1 - - if idx_1 == len(nums_1): break # Array 1 can't catch up. + + if idx_1 == len(nums_1): + break # Array 1 can't catch up. while idx_2 < len(nums_2) and nums_2[idx_2] < nums_1[idx_1]: score_2 += nums_2[idx_2] idx_2 += 1 - - if idx_2 == len(nums_2): break # Array 2 can't catch up. + + if idx_2 == len(nums_2): + break # Array 2 can't catch up. if nums_1[idx_1] == nums_2[idx_2]: # Arrays can now compare scores. score_1 += nums_1[idx_1] score_2 += nums_2[idx_2] max_score += max(score_1, score_2) - if max_score > modulo: max_score %= modulo # Control size. - + if max_score > modulo: + max_score %= modulo # Control size. + score_1, score_2 = 0, 0 # Reset for next while iteration. idx_1 += 1 idx_2 += 1 diff --git a/docs/two_pointers/1793_hard/good_subarray_score.cpp b/docs/two_pointers/1793_hard/good_subarray_score.cpp index c7ae96b0..0c311e03 100644 --- a/docs/two_pointers/1793_hard/good_subarray_score.cpp +++ b/docs/two_pointers/1793_hard/good_subarray_score.cpp @@ -1,8 +1,7 @@ #include using namespace std; -int findMaxScore(vector& nums, int k) // LeetCode Q.1793. -{ +int findMaxScore(vector& nums, int k) { int maxScore = nums[k], minNum = nums[k]; // Base case. int leftIdx = k, rightIdx = k; diff --git a/docs/two_pointers/1793_hard/good_subarray_score.py b/docs/two_pointers/1793_hard/good_subarray_score.py index 6888f9b7..bb27dec3 100644 --- a/docs/two_pointers/1793_hard/good_subarray_score.py +++ b/docs/two_pointers/1793_hard/good_subarray_score.py @@ -1,5 +1,4 @@ - -def find_max_score(nums: list[int], k: int) -> int: # LeetCode Q.1793. +def find_max_score(nums: list[int], k: int) -> int: max_score = nums[k] # Base case. min_num = nums[k] @@ -9,7 +8,7 @@ def find_max_score(nums: list[int], k: int) -> int: # LeetCode Q.1793. if left_idx == 0: # Can only go right. right_idx += 1 min_num = min(min_num, nums[right_idx]) - + elif right_idx == len(nums) - 1: # Can only go left. left_idx -= 1 min_num = min(min_num, nums[left_idx]) diff --git a/files_generators/problems_json_generator.py b/files_generators/problems_json_generator.py index 57a25d0b..ff9175b4 100644 --- a/files_generators/problems_json_generator.py +++ b/files_generators/problems_json_generator.py @@ -7,17 +7,21 @@ for dsa_topic in sorted(os.listdir(DOCS_DIR_PATH)): dsa_topic_path = os.path.join(DOCS_DIR_PATH, dsa_topic) - if not os.path.isdir(dsa_topic_path): continue + if not os.path.isdir(dsa_topic_path): + continue for problem in sorted(os.listdir(dsa_topic_path)): problem_path = os.path.join(dsa_topic_path, problem) - if not os.path.isdir(problem_path): continue + if not os.path.isdir(problem_path): + continue parts = problem.split("_") - if len(parts) < 2: continue + if len(parts) < 2: + continue difficulty = parts[1].lower() - if difficulty not in DIFFICULTIES: continue + if difficulty not in DIFFICULTIES: + continue number_str = parts[0] # Has left padded zeros. number = int(parts[0]) @@ -35,13 +39,15 @@ if line.startswith("title:"): title = line.replace("title:", "").strip().strip('"') - if line == "---": break + if line == "---": + break stem = file.rsplit(".", 1)[0] doc_id = f"{dsa_topic}/{problem}/{stem}" break - if not title or not doc_id: continue + if not title or not doc_id: + continue image = None # Find efficiency png. diff --git a/files_generators/sidebars_ts_generator.py b/files_generators/sidebars_ts_generator.py index 76a9f85b..5a790ef1 100644 --- a/files_generators/sidebars_ts_generator.py +++ b/files_generators/sidebars_ts_generator.py @@ -13,7 +13,8 @@ def get_md_title(md_path: str, fallback: str) -> str: if line.startswith("title:"): return line.replace("title:", "").strip().strip('"') - if line == "---": break + if line == "---": + break return fallback @@ -27,18 +28,22 @@ def generate_sidebars() -> None: for dsa_topic in sorted(os.listdir(DOCS_DIR_PATH)): # Sort DSA topics. topic_path = os.path.join(DOCS_DIR_PATH, dsa_topic) - if not os.path.isdir(topic_path): continue + if not os.path.isdir(topic_path): + continue groups = {} for problem in sorted(os.listdir(topic_path)): # Sort w.r.t. problems' numbers. problem_path = os.path.join(topic_path, problem) - if not os.path.isdir(problem_path): continue + if not os.path.isdir(problem_path): + continue parts = problem.split("_") - if len(parts) < 2: continue + if len(parts) < 2: + continue difficulty = parts[1].lower() - if difficulty not in DIFFICULTIES: continue + if difficulty not in DIFFICULTIES: + continue number = parts[0] @@ -62,15 +67,17 @@ def generate_sidebars() -> None: } ) - if not groups: continue + if not groups: + continue diff_categories = [] for diff in DIFFICULTIES: - if diff not in groups: continue + if diff not in groups: + continue base_label = diff.capitalize() count = diff_label_counter.get(base_label, 0) - unique_label = base_label + "\u200B" * count # Add zero-width spaces. + unique_label = base_label + "\u200b" * count # Add zero-width spaces. diff_label_counter[base_label] = count + 1 diff_categories.append( diff --git a/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.cpp b/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.cpp index d31e2e80..c469e5e7 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.cpp +++ b/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.cpp @@ -1,8 +1,7 @@ #include using namespace std; -bool judgeWinnability(int stonesCount) // LeetCode Q.1510. -{ +bool judgeWinnability(int stonesCount) { vector squaresCounts(stonesCount + 1, 0); for (int num = 1; num <= stonesCount; num++) { diff --git a/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.py b/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.py index cfe318a0..95d8b3f1 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.py +++ b/i18n/en/docusaurus-plugin-content-docs/current/dp_tabulation/1510_hard/perfect_stone_game.py @@ -1,15 +1,14 @@ - -def judge_winnability(stones_count: int) -> bool: # LeetCode Q.1510. +def judge_winnability(stones_count: int) -> bool: squares_counts = [0] * (stones_count + 1) for num in range(1, stones_count + 1): - max_sqrt = int(num ** 0.5) - if max_sqrt ** 2 == num: + max_sqrt = int(num**0.5) + if max_sqrt**2 == num: squares_counts[num] += 1 # From 0 to 1. continue for sqrt in range(max_sqrt, 0, -1): - residual = num - (sqrt ** 2) + residual = num - (sqrt**2) if squares_counts[residual] == 0: squares_counts[num] += 1 # From 0 to 1. break diff --git a/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.cpp b/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.cpp index 121fe0d6..57d6b813 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.cpp +++ b/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.cpp @@ -2,7 +2,7 @@ #include using namespace std; -long long count_subarrays(vector& nums) { // LeetCode Q.3113. +long long count_subarrays(vector& nums) { stack> stack; // Format: {num, count}. long long subarraysCount = 0; diff --git a/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.py b/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.py index 9edeca69..7724aba3 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.py +++ b/i18n/en/docusaurus-plugin-content-docs/current/stack/3113_hard/max_boundary_subarrays.py @@ -1,5 +1,4 @@ - -def count_subarrays(nums: list[int]) -> int: # LeetCode Q.3113. +def count_subarrays(nums: list[int]) -> int: stack: list[tuple[int, int]] = [] # Format: (num, count). subarrays_count = 0 @@ -7,7 +6,7 @@ def count_subarrays(nums: list[int]) -> int: # LeetCode Q.3113. for num in nums: while stack and stack[-1][0] < num: stack.pop(-1) - + count = 1 # Base case: current num only. if stack and stack[-1][0] == num: diff --git a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.cpp b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.cpp index a9aa3496..b9ebb912 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.cpp +++ b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.cpp @@ -2,7 +2,7 @@ #include using namespace std; -int findMaxScore(vector& nums1, vector& nums2) { // LeetCode Q.1537. +int findMaxScore(vector& nums1, vector& nums2) { long long maxScore = 0; // Must use long long to prevent overflow. long long scoreOne = 0, scoreTwo = 0; diff --git a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.py b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.py index 666b3d9d..0ac46863 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.py +++ b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1537_hard/max_score.py @@ -1,7 +1,6 @@ - -def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: # LeetCode Q.1537. +def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: max_score = 0 - modulo = 10 ** 9 + 7 + modulo = 10**9 + 7 score_1, score_2 = 0, 0 @@ -11,22 +10,25 @@ def find_max_score(nums_1: list[int], nums_2: list[int]) -> int: # LeetCode Q.1 while idx_1 < len(nums_1) and nums_1[idx_1] < nums_2[idx_2]: score_1 += nums_1[idx_1] idx_1 += 1 - - if idx_1 == len(nums_1): break # Array 1 can't catch up. + + if idx_1 == len(nums_1): + break # Array 1 can't catch up. while idx_2 < len(nums_2) and nums_2[idx_2] < nums_1[idx_1]: score_2 += nums_2[idx_2] idx_2 += 1 - - if idx_2 == len(nums_2): break # Array 2 can't catch up. + + if idx_2 == len(nums_2): + break # Array 2 can't catch up. if nums_1[idx_1] == nums_2[idx_2]: # Arrays can now compare scores. score_1 += nums_1[idx_1] score_2 += nums_2[idx_2] max_score += max(score_1, score_2) - if max_score > modulo: max_score %= modulo # Control size. - + if max_score > modulo: + max_score %= modulo # Control size. + score_1, score_2 = 0, 0 # Reset for next while iteration. idx_1 += 1 idx_2 += 1 diff --git a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.cpp b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.cpp index c7ae96b0..0c311e03 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.cpp +++ b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.cpp @@ -1,8 +1,7 @@ #include using namespace std; -int findMaxScore(vector& nums, int k) // LeetCode Q.1793. -{ +int findMaxScore(vector& nums, int k) { int maxScore = nums[k], minNum = nums[k]; // Base case. int leftIdx = k, rightIdx = k; diff --git a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.py b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.py index 6888f9b7..bb27dec3 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.py +++ b/i18n/en/docusaurus-plugin-content-docs/current/two_pointers/1793_hard/good_subarray_score.py @@ -1,5 +1,4 @@ - -def find_max_score(nums: list[int], k: int) -> int: # LeetCode Q.1793. +def find_max_score(nums: list[int], k: int) -> int: max_score = nums[k] # Base case. min_num = nums[k] @@ -9,7 +8,7 @@ def find_max_score(nums: list[int], k: int) -> int: # LeetCode Q.1793. if left_idx == 0: # Can only go right. right_idx += 1 min_num = min(min_num, nums[right_idx]) - + elif right_idx == len(nums) - 1: # Can only go left. left_idx -= 1 min_num = min(min_num, nums[left_idx]) diff --git a/package.json b/package.json index 6cb165ed..a9c24807 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,13 @@ "serve": "docusaurus serve", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc" + "typecheck": "tsc", + "lint:py": "black -S --check --diff docs i18n files_generators *.py", + "format:py": "black -S docs i18n files_generators *.py", + "lint:cpp": "find docs i18n -type f \\( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) -print0 | xargs -0 clang-format --dry-run -Werror", + "format:cpp": "find docs i18n -type f \\( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) -print0 | xargs -0 clang-format -i", + "lint": "npm run lint:py && npm run lint:cpp", + "format": "npm run format:py && npm run format:cpp" }, "dependencies": { "@docusaurus/core": "3.10.1", From b530382bff0956121bcec11374e36085cb1fca6c Mon Sep 17 00:00:00 2001 From: Jack Yao <105488074+StarsExpress@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:47:11 -0500 Subject: [PATCH 2/4] Trigger CI. From b8cf154ad66803c00ce172622399bbc4a127752e Mon Sep 17 00:00:00 2001 From: Jack Yao <105488074+StarsExpress@users.noreply.github.com> Date: Fri, 24 Jul 2026 17:10:41 -0500 Subject: [PATCH 3/4] Adjusted linters. --- .github/workflows/black-lint.yml | 2 +- .github/workflows/clang-format-lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml index 6fd6f4de..cb02c557 100644 --- a/.github/workflows/black-lint.yml +++ b/.github/workflows/black-lint.yml @@ -9,7 +9,7 @@ on: - files_generators/** - '*.py' pull_request: - branches: [main] + branches: [dev] paths: - docs/** - i18n/** diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index dd931164..2ea08814 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -12,7 +12,7 @@ on: - '**.h' - '**.hpp' pull_request: - branches: [main] + branches: [dev] paths: - docs/** - i18n/** From 19e19b02e621c2fc68a5320873276c8a57d036c4 Mon Sep 17 00:00:00 2001 From: Jack Yao <105488074+StarsExpress@users.noreply.github.com> Date: Fri, 24 Jul 2026 17:19:13 -0500 Subject: [PATCH 4/4] Adjusted linters & upgraded black version. --- .github/workflows/black-lint.yml | 2 +- .github/workflows/clang-format-lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml index cb02c557..6fd6f4de 100644 --- a/.github/workflows/black-lint.yml +++ b/.github/workflows/black-lint.yml @@ -9,7 +9,7 @@ on: - files_generators/** - '*.py' pull_request: - branches: [dev] + branches: [main] paths: - docs/** - i18n/** diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 2ea08814..dd931164 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -12,7 +12,7 @@ on: - '**.h' - '**.hpp' pull_request: - branches: [dev] + branches: [main] paths: - docs/** - i18n/**