mirror of
https://github.com/Xevion/leetcode.git
synced 2025-12-06 17:15:29 -06:00
Sort questions, move header/separator rows into template, remove hyperlink from ID column
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
This repository contains my solutions to various problems on [LeetCode](https://leetcode.com/).
|
This repository contains my solutions to various problems on [LeetCode](https://leetcode.com/).
|
||||||
|
|
||||||
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py).
|
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py)automatically generated.
|
||||||
|
| # | Title | Solution | Difficulty |
|
||||||
{{ table }}
|
|---| ----- | -------- | ---------- |
|
||||||
|
{{ rows }}
|
||||||
|
|
||||||
<sub>
|
<sub>
|
||||||
Generated on {{ date }}
|
Generated on {{ date }}
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ def main():
|
|||||||
cache_path=ROOT_DIRECTORY / "questions.json", cache_time=60 * 60 * 24
|
cache_path=ROOT_DIRECTORY / "questions.json", cache_time=60 * 60 * 24
|
||||||
)
|
)
|
||||||
|
|
||||||
table = [
|
table = []
|
||||||
"| # | Title | Solution | Difficulty |",
|
|
||||||
"|-|-|-|-|",
|
|
||||||
]
|
|
||||||
|
|
||||||
children = list(SOLUTIONS_DIRECTORY.glob("*/"))
|
children = list(SOLUTIONS_DIRECTORY.glob("*/"))
|
||||||
logger.debug(f"Found {len(children)} children.")
|
logger.debug(f"Found {len(children)} children.")
|
||||||
@@ -90,24 +87,24 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
columns = [
|
columns = [
|
||||||
f"[{question.id}]({question.url})",
|
question.id,
|
||||||
f"[{question.title}]({question.url})",
|
f"[{question.title}]({question.url})",
|
||||||
solutions,
|
solutions,
|
||||||
question.difficulty,
|
question.difficulty,
|
||||||
]
|
]
|
||||||
|
|
||||||
row = "| " + " | ".join(map(str, columns)) + " |"
|
row = "| " + " | ".join(map(str, columns)) + " |"
|
||||||
|
table.append((question.id, row))
|
||||||
|
|
||||||
table.append(row)
|
table.sort(key=lambda row: row[0])
|
||||||
|
rows = "\n".join(row[1] for row in table)
|
||||||
table = "\n".join(table)
|
|
||||||
|
|
||||||
with TEMPLATE_PATH.open("r") as template_file:
|
with TEMPLATE_PATH.open("r") as template_file:
|
||||||
template = Template(template_file.read())
|
template = Template(template_file.read())
|
||||||
|
|
||||||
with (ROOT_DIRECTORY / "README.md").open("w") as readme_file:
|
with (ROOT_DIRECTORY / "README.md").open("w") as readme_file:
|
||||||
readme_file.write(
|
readme_file.write(
|
||||||
template.render(date=datetime.now().strftime("%Y-%m-%d"), table=table)
|
template.render(date=datetime.now().strftime("%Y-%m-%d"), rows=rows)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class QuestionDatabase(object):
|
|||||||
self.questions = [
|
self.questions = [
|
||||||
Question(**question) for question in raw_cache["questions"]
|
Question(**question) for question in raw_cache["questions"]
|
||||||
]
|
]
|
||||||
logger.info(f"Loaded {len(self.questions)} questions from cache.")
|
logger.info(f"Loaded {len(self.questions):,} questions from cache.")
|
||||||
else:
|
else:
|
||||||
logger.info(f"Cache file {cache_path} does not exist.")
|
logger.info(f"Cache file {cache_path} does not exist.")
|
||||||
|
|
||||||
|
|||||||
39
README.md
39
README.md
@@ -2,27 +2,26 @@
|
|||||||
|
|
||||||
This repository contains my solutions to various problems on [LeetCode](https://leetcode.com/).
|
This repository contains my solutions to various problems on [LeetCode](https://leetcode.com/).
|
||||||
|
|
||||||
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py).
|
Below is the full table containing all the problems I have solved so far. The table is [automatically generated](./.generate/main.py)automatically generated.
|
||||||
|
|
||||||
| # | Title | Solution | Difficulty |
|
| # | Title | Solution | Difficulty |
|
||||||
|-|-|-|-|
|
|---| ----- | -------- | ---------- |
|
||||||
| [8](https://leetcode.com/problems/string-to-integer-atoi) | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi) | [Java](/solutions/string-to-integer-atoi/Solution.java) | Medium |
|
| 1 | [Two Sum](https://leetcode.com/problems/two-sum) | [Java](/solutions/two-sum/Solution.java) | Easy |
|
||||||
| [5](https://leetcode.com/problems/longest-palindromic-substring) | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring) | [Java](/solutions/longest-palindromic-substring/Solution.java) | Medium |
|
| 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers) | [Java](/solutions/add-two-numbers/Solution.java) | Medium |
|
||||||
| [1636](https://leetcode.com/problems/sort-array-by-increasing-frequency) | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency) | [Java](/solutions/sort-array-by-increasing-frequency/Solution.java) | Easy |
|
| 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters) | [Java](/solutions/longest-substring-without-repeating-characters/Solution.java) | Medium |
|
||||||
| [1](https://leetcode.com/problems/two-sum) | [Two Sum](https://leetcode.com/problems/two-sum) | [Java](/solutions/two-sum/Solution.java) | Easy |
|
| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays) | [Rust (Two Pointers)](/solutions/median-of-two-sorted-arrays/src/bin/two-pointers.rs) | Hard |
|
||||||
| [1608](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x) | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x) | [Java](/solutions/special-array-with-x-elements-greater-than-or-equal-x/Solution.java) | Easy |
|
| 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring) | [Java](/solutions/longest-palindromic-substring/Solution.java) | Medium |
|
||||||
| [4](https://leetcode.com/problems/median-of-two-sorted-arrays) | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays) | [Rust (Two Pointers)](/solutions/median-of-two-sorted-arrays/src/bin/two-pointers.rs) | Hard |
|
| 6 | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion) | [Java](/solutions/zigzag-conversion/Solution.java) | Medium |
|
||||||
| [2](https://leetcode.com/problems/add-two-numbers) | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers) | [Java](/solutions/add-two-numbers/Solution.java) | Medium |
|
| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer) | [Java](/solutions/reverse-integer/Solution.java) | Medium |
|
||||||
| [1048](https://leetcode.com/problems/longest-string-chain) | [Longest String Chain](https://leetcode.com/problems/longest-string-chain) | [Java](/solutions/longest-string-chain/Solution.java) | Medium |
|
| 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi) | [Java](/solutions/string-to-integer-atoi/Solution.java) | Medium |
|
||||||
| [7](https://leetcode.com/problems/reverse-integer) | [Reverse Integer](https://leetcode.com/problems/reverse-integer) | [Java](/solutions/reverse-integer/Solution.java) | Medium |
|
| 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number) | [Java](/solutions/palindrome-number/Solution.java) | Easy |
|
||||||
| [6](https://leetcode.com/problems/zigzag-conversion) | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion) | [Java](/solutions/zigzag-conversion/Solution.java) | Medium |
|
| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer) | [Java](/solutions/roman-to-integer/Solution.java) | Easy |
|
||||||
| [9](https://leetcode.com/problems/palindrome-number) | [Palindrome Number](https://leetcode.com/problems/palindrome-number) | [Java](/solutions/palindrome-number/Solution.java) | Easy |
|
| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self) | [Rust](/solutions/product-of-array-except-self/src/main.rs) | Medium |
|
||||||
| [238](https://leetcode.com/problems/product-of-array-except-self) | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self) | [Rust](/solutions/product-of-array-except-self/src/main.rs) | Medium |
|
| 387 | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string) | [Java](/solutions/first-unique-character-in-a-string/Solution.java), [Java (HashMap)](/solutions/first-unique-character-in-a-string/Solution_HashMap.java) | Easy |
|
||||||
| [13](https://leetcode.com/problems/roman-to-integer) | [Roman to Integer](https://leetcode.com/problems/roman-to-integer) | [Java](/solutions/roman-to-integer/Solution.java) | Easy |
|
| 451 | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency) | [Java](/solutions/sort-characters-by-frequency/Solution.java) | Medium |
|
||||||
| [3](https://leetcode.com/problems/longest-substring-without-repeating-characters) | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters) | [Java](/solutions/longest-substring-without-repeating-characters/Solution.java) | Medium |
|
| 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain) | [Java](/solutions/longest-string-chain/Solution.java) | Medium |
|
||||||
| [387](https://leetcode.com/problems/first-unique-character-in-a-string) | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string) | [Java](/solutions/first-unique-character-in-a-string/Solution.java), [Java (HashMap)](/solutions/first-unique-character-in-a-string/Solution_HashMap.java) | Easy |
|
| 1487 | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique) | [Java](/solutions/making-file-names-unique/Solution.java), [Java (RegEx)](/solutions/making-file-names-unique/Solution_regex.java), [Python](/solutions/making-file-names-unique/Solution.py) | Medium |
|
||||||
| [1487](https://leetcode.com/problems/making-file-names-unique) | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique) | [Java](/solutions/making-file-names-unique/Solution.java), [Java (RegEx)](/solutions/making-file-names-unique/Solution_regex.java), [Python](/solutions/making-file-names-unique/Solution.py) | Medium |
|
| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x) | [Java](/solutions/special-array-with-x-elements-greater-than-or-equal-x/Solution.java) | Easy |
|
||||||
| [451](https://leetcode.com/problems/sort-characters-by-frequency) | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency) | [Java](/solutions/sort-characters-by-frequency/Solution.java) | Medium |
|
| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency) | [Java](/solutions/sort-array-by-increasing-frequency/Solution.java) | Easy |
|
||||||
|
|
||||||
<sub>
|
<sub>
|
||||||
Generated on 2023-10-08
|
Generated on 2023-10-08
|
||||||
|
|||||||
Reference in New Issue
Block a user