This commit is contained in:
2026-06-05 22:32:49 +08:00
parent 14d05011d5
commit c67841fe07
202 changed files with 498 additions and 403 deletions
@@ -54,13 +54,13 @@ Explanation: The endWord "cog" is not in wordList, therefore there is no valid t
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 127 :lc-lang python3
class Solution:
def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 127
class Solution {
public:
int ladderLength(string beginWord, string endWord, vector<string>& wordList) {
@@ -44,7 +44,7 @@ In the above diagram, the bottom region is not captured because it is on the edg
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 130 :lc-lang python3
class Solution:
def solve(self, board: List[List[str]]) -> None:
"""
@@ -53,7 +53,7 @@ class Solution:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 130
class Solution {
public:
void solve(vector<vector<char>>& board) {
@@ -77,7 +77,7 @@ Explanation: This an empty graph, it does not have any nodes.
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 133 :lc-lang python3
"""
# Definition for a Node.
class Node:
@@ -92,7 +92,7 @@ class Solution:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 133
/*
// Definition for a Node.
class Node {
@@ -50,13 +50,13 @@ Output: 3
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 200 :lc-lang python3
class Solution:
def numIslands(self, grid: List[List[str]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 200
class Solution {
public:
int numIslands(vector<vector<char>>& grid) {
@@ -48,13 +48,13 @@ To take course 1 you should have finished course 0, and to take course 0 you sho
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 207 :lc-lang python3
class Solution:
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 207
class Solution {
public:
bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {
@@ -58,13 +58,13 @@ Output: [0]
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 210 :lc-lang python3
class Solution:
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 210
class Solution {
public:
vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) {
@@ -8,11 +8,11 @@
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 261 :lc-lang python3
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 261
#+end_src
@@ -8,11 +8,11 @@
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 286 :lc-lang python3
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 286
#+end_src
@@ -8,11 +8,11 @@
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 323 :lc-lang python3
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 323
#+end_src
@@ -61,13 +61,13 @@ Explanation: The water can flow from the only cell to the Pacific and Atlantic o
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 417 :lc-lang python3
class Solution:
def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 417
class Solution {
public:
vector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {
@@ -48,13 +48,13 @@ Output: [1,4]
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 684 :lc-lang python3
class Solution:
def findRedundantConnection(self, edges: List[List[int]]) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 684
class Solution {
public:
vector<int> findRedundantConnection(vector<vector<int>>& edges) {
@@ -43,13 +43,13 @@ Output: 0
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 695 :lc-lang python3
class Solution:
def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 695
class Solution {
public:
int maxAreaOfIsland(vector<vector<int>>& grid) {
@@ -53,13 +53,13 @@ Only node 4 is a terminal node, and every path starting at node 4 leads to node
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 802 :lc-lang python3
class Solution:
def eventualSafeNodes(self, graph: List[List[int]]) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 802
class Solution {
public:
vector<int> eventualSafeNodes(vector<vector<int>>& graph) {
@@ -59,13 +59,13 @@ Explanation: Since there are already no fresh oranges at minute 0, the answer is
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 994 :lc-lang python3
class Solution:
def orangesRotting(self, grid: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 994
class Solution {
public:
int orangesRotting(vector<vector<int>>& grid) {
@@ -46,13 +46,13 @@ The 1s colored red in grid2 are those considered to be part of a sub-island. The
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 1905 :lc-lang python3
class Solution:
def countSubIslands(self, grid1: List[List[int]], grid2: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 1905
class Solution {
public:
int countSubIslands(vector<vector<int>>& grid1, vector<vector<int>>& grid2) {
@@ -76,13 +76,13 @@ Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2092 :lc-lang python3
class Solution:
def findAllPeople(self, n: int, meetings: List[List[int]], firstPerson: int) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2092
class Solution {
public:
vector<int> findAllPeople(int n, vector<vector<int>>& meetings, int firstPerson) {
@@ -54,13 +54,13 @@ Explanation: The fisher can start at cells (0,0) or (3,3) and collect a single f
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2658 :lc-lang python3
class Solution:
def findMaxFish(self, grid: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2658
class Solution {
public:
int findMaxFish(vector<vector<int>>& grid) {
@@ -62,13 +62,13 @@ Explanation: Team 2 is weaker than team 0 and team 1. Team 3 is weaker than team
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2924 :lc-lang python3
class Solution:
def findChampion(self, n: int, edges: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2924
class Solution {
public:
int findChampion(int n, vector<vector<int>>& edges) {