feat: populate note files with problem descriptions and code stubs
Add populate-notes.mjs that fetches problem descriptions and Python/C++ code stubs from LeetCode's GraphQL API. Populated all 197 NeetCode 150 note files with: - Problem description (examples, constraints) - Python code stub (function signature) - C++ code stub (function signature + includes) API responses cached in leetcode/.cache/leetcode/ for instant re-runs.
This commit is contained in:
@@ -1,18 +1,63 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0130. Surrounded Regions :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0130. Surrounded Regions][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0130. Surrounded Regions][0130. Surrounded Regions]]
|
||||
:END:
|
||||
|
||||
You are given an ~m x n~ matrix ~board~ containing *letters* ~'X'~ and ~'O'~, *capture regions* that are *surrounded*:
|
||||
|
||||
- *Connect*: A cell is connected to adjacent cells horizontally or vertically.
|
||||
|
||||
- *Region*: To form a region *connect every* ~'O'~ cell.
|
||||
|
||||
- *Surround*: A region is surrounded if none of the ~'O'~ cells in that region are on the edge of the board. Such regions are *completely enclosed *by ~'X'~ cells.
|
||||
|
||||
To capture a *surrounded region*, replace all ~'O'~s with ~'X'~s *in-place* within the original board. You do not need to return anything.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
*Input:* board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]
|
||||
|
||||
*Output:* [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]
|
||||
|
||||
*Explanation:*
|
||||
|
||||
In the above diagram, the bottom region is not captured because it is on the edge of the board and cannot be surrounded.
|
||||
|
||||
*Example 2:*
|
||||
|
||||
*Input:* board = [["X"]]
|
||||
|
||||
*Output:* [["X"]]
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~m == board.length~
|
||||
|
||||
- ~n == board[i].length~
|
||||
|
||||
- ~1 <= m, n <= 200~
|
||||
|
||||
- ~board[i][j]~ is ~'X'~ or ~'O'~.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def solve(self, board: List[List[str]]) -> None:
|
||||
"""
|
||||
Do not return anything, modify board in-place instead.
|
||||
"""
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
void solve(vector<vector<char>>& board) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user