Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
# ====================================================
semantic-release:
name: semantic-release
uses: wislertt/zerv/.github/workflows/shared-semantic-release.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-semantic-release.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18
with:
allowed_workflow_dispatch_branches: '["main"]'
fail_on_invalid_workflow_dispatch_ref: true

zerv-versioning:
needs: semantic-release
if: needs.semantic-release.outputs.is_valid_semantic_release == 'true'
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18

create-version-prefix-tags:
needs: zerv-versioning
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18
with:
tags: >-
[
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# ====================================================
check-pre-release:
name: check-pre-release
uses: wislertt/zerv/.github/workflows/shared-check-pr-label-and-branch.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-check-pr-label-and-branch.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18
with:
target_label: "pre-release"
branch_prefixes: '["release/"]'
Expand All @@ -23,7 +23,7 @@ jobs:
zerv-versioning:
name: zerv-versioning
needs: check-pre-release
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18
with:
schema: >-
${{ (needs.check-pre-release.outputs.is_valid == 'true'
Expand All @@ -34,7 +34,7 @@ jobs:
name: tag-pre-release
needs: [zerv-versioning, check-pre-release]
if: needs.check-pre-release.outputs.is_valid == 'true'
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@3b80a91e86ee2cca01ff75ba39a177c1f13fd810 # v0.8.18
with:
tags: '["${{ fromJson(needs.zerv-versioning.outputs.versions).v_semver }}"]'

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}

- name: setup-mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0

- name: cache-deps
env:
CACHE_KEY_PREFIX: deps-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock', '.pre-commit-config.yaml') }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/pre-commit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:

steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: set-python-version
run: echo "${{ inputs.python_version }}" > .python-version

- name: setup-mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0

- name: install-dependencies
run: uv sync --all-extras --all-groups --frozen
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Run Trivy dependency scan
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-reproducibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:

steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: setup-mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0

- name: cache-venv
env:
CACHE_KEY_PREFIX: venv-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock') }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.local/share/uv
Expand All @@ -40,7 +40,7 @@ jobs:
id: cache-graphviz
env:
CACHE_KEY_PREFIX: graphviz-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/graphviz-cache
key: ${{ env.CACHE_KEY_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ jobs:

steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0

- name: set-python-version
run: echo "${{ matrix.python-version }}" > .python-version

- name: setup-mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0

- name: cache-venv
env:
CACHE_KEY_PREFIX: venv-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-py${{ matrix.python-version }}
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock') }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.local/share/uv
Expand All @@ -61,7 +61,7 @@ jobs:
id: cache-graphviz
env:
CACHE_KEY_PREFIX: graphviz-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/graphviz-cache
key: ${{ env.CACHE_KEY_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}
Expand Down
2 changes: 1 addition & 1 deletion bakefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class MyBakebook(GitHubActionsTools, PythonLibSpace):
ci: bool = False
problem: str = "walls_and_gates"
problem: str = "longest_valid_parentheses"

def lint(self) -> None:
self.ctx.run("uv run python scripts/sort_tags.py")
Expand Down
2 changes: 1 addition & 1 deletion leetcode/alien_dictionary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ There is a new alien language that uses the English alphabet. However, the order

You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language.

Return _a string of the unique letters in the new alien language sorted in **lexicographically increasing order** by the new language's rules. If there is no solution, return_ `""`\*. If there are multiple solutions, return **any of them\***.
Return _a string of the unique letters in the new alien language sorted in **lexicographically increasing order** by the new language's rules. If there is no solution, return_ `""`_. If there are multiple solutions, return **any of them**_.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion leetcode/alien_dictionary/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/cheapest_flights_within_k_stops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The optimal path with no stops from city 0 to 2 is marked in red and has cost 50
## Constraints

- 2 <= n <= 100
- 0 <= flights.length <= (n \* (n - 1) / 2)
- 0 <= flights.length <= (n * (n - 1) / 2)
- flights[i].length == 3
- 0 <= fromi, toi < n
- fromi != toi
Expand Down
2 changes: 1 addition & 1 deletion leetcode/cheapest_flights_within_k_stops/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/counting_bits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Problem Description

Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` _(0 <= i <= n),_ `ans[i]` \*is the **number of\*** `1`**\*'s** in the binary representation of\* `i`.
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` _(0 <= i <= n),_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion leetcode/counting_bits/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
4 changes: 2 additions & 2 deletions leetcode/evaluate_reverse_polish_notation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Input: tokens = ["2","1","+","3","*"]
Output: 9
```

**Explanation:** ((2 + 1) \* 3) = 9
**Explanation:** ((2 + 1) * 3) = 9

### Example 2:

Expand All @@ -48,7 +48,7 @@ Input: tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]
Output: 22
```

**Explanation:** ((10 _ (6 / ((9 + 3) _ -11))) + 17) + 5 = 22
**Explanation:** ((10 * (6 / ((9 + 3) * -11))) + 17) + 5 = 22

## Constraints

Expand Down
2 changes: 1 addition & 1 deletion leetcode/evaluate_reverse_polish_notation/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/find_all_anagrams_in_a_string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ The substring with start index = 2 is "ab", which is an anagram of "ab".

## Constraints

- 1 <= s.length, p.length <= 3 \* 10^4
- 1 <= s.length, p.length <= 3 * 10^4
- s and p consist of lowercase English letters.
2 changes: 1 addition & 1 deletion leetcode/find_all_anagrams_in_a_string/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/house_robber/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and **it will automatically contact the police if two adjacent houses were broken into on the same night**.

Given an integer array `nums` representing the amount of money of each house, return \*the maximum amount of money you can rob tonight **without alerting the police\***.
Given an integer array `nums` representing the amount of money of each house, return _the maximum amount of money you can rob tonight **without alerting the police**_.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion leetcode/house_robber/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/house_robber_ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatically contact the police if two adjacent houses were broken into on the same night**.

Given an integer array `nums` representing the amount of money of each house, return \*the maximum amount of money you can rob tonight **without alerting the police\***.
Given an integer array `nums` representing the amount of money of each house, return _the maximum amount of money you can rob tonight **without alerting the police**_.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion leetcode/house_robber_ii/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
2 changes: 1 addition & 1 deletion leetcode/is_graph_bipartite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ There is an undirected graph with `n` nodes, where each node is numbered between

A graph is **bipartite** if the nodes can be partitioned into two independent sets `A` and `B` such that **every** edge in the graph connects a node in set `A` and a node in set `B`.

Return `true` \*if and only if it is **bipartite\***.
Return `true` _if and only if it is **bipartite**_.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion leetcode/is_graph_bipartite/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.4
# kernelspec:
# display_name: leetcode-py-py3.13
# language: python
Expand Down
36 changes: 36 additions & 0 deletions leetcode/longest_common_prefix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Longest Common Prefix

**Difficulty:** Easy
**Topics:** Array, String, Trie
**Tags:** grind

**LeetCode:** [Problem 14](https://leetcode.com/problems/longest-common-prefix/description/)

## Problem Description

Write a function to find the longest common prefix string amongst an array of strings.

If there is no common prefix, return an empty string `""`.

## Examples

### Example 1:

```
Input: strs = ["flower","flow","flight"]
Output: "fl"
```

### Example 2:

```
Input: strs = ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.
```

## Constraints

- 1 <= strs.length <= 200
- 0 <= strs[i].length <= 200
- `strs[i]` consists of only lowercase English letters if it is non-empty.
Empty file.
8 changes: 8 additions & 0 deletions leetcode/longest_common_prefix/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def run_longest_common_prefix(solution_class: type, strs: list[str]):
implementation = solution_class()
return implementation.longest_common_prefix(strs)


def assert_longest_common_prefix(result: str, expected: str) -> bool:
assert result == expected
return True
Loading