Compare commits
9 Commits
cf158eafdf
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e10cc4257d | |||
| c67841fe07 | |||
| 14d05011d5 | |||
| 0aed1528e2 | |||
| 0f9312eaee | |||
| c9fe2fab76 | |||
| 03561f8d10 | |||
| fc6e664ff9 | |||
| 7659303fb0 |
@@ -48,6 +48,6 @@ Periodically review this file and suggest improvements to the user if you notice
|
||||
<!-- Updated automatically by /self-improve. Remove stale entries. -->
|
||||
- Branch: `master`, up to date with origin
|
||||
- DSA notes moved from `org/cpp/dsa/` to `org/study_deck_02/dsa/`
|
||||
- All files carry `#+PROPERTY: STUDY_DECK_02` for org-anki export
|
||||
- All files carry `#+ANKI_DECK: study_deck_02` for org-anki export
|
||||
- Inbox items: binary search, `using` keyword — need cards created
|
||||
- Possible cleanup: `org/study_deck_02/dsa/udfs.org` may be a stale draft of `org/cpp/ufds.org`
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
((org-mode . ((org-todo-keywords . ((sequence "TODO" | "DONE" "TOO_EASY")))
|
||||
(eval . (let ((lc-el (expand-file-name "lc-org.el" (dir-locals-find-file default-directory))))
|
||||
(when (and lc-el (file-exists-p lc-el))
|
||||
(load-file lc-el)
|
||||
(lc-org-mode 1)))))))
|
||||
@@ -14,7 +14,12 @@ An Anki-exportable study deck for NeetCode DSA problems.
|
||||
- Python and C++ solution stubs
|
||||
- A `NEETCODE` property linking back to the roadmap
|
||||
|
||||
3. **Study flow** — open roadmap.org, pick a topic, pick a problem,
|
||||
3. **Toolkit** (`toolkit/`) — your reference library:
|
||||
- `tricks.org` — flashcards for patterns & tricks (exported to Anki)
|
||||
- `notes.org` — deep implementation notes with explanations (exported to Anki)
|
||||
- `suggestions.org` — pattern reference for quick lookup (not exported)
|
||||
|
||||
4. **Study flow** — open roadmap.org, pick a topic, pick a problem,
|
||||
follow the Notes link, solve it, mark it DONE in both places.
|
||||
|
||||
## File Layout
|
||||
@@ -23,6 +28,11 @@ An Anki-exportable study deck for NeetCode DSA problems.
|
||||
org/study_deck_02/
|
||||
├── AGENTS.md ← you are here
|
||||
├── roadmap.org ← generated by leetcode/extract.mjs
|
||||
├── toolkit/
|
||||
│ ├── tricks.org ← flashcards for patterns & tricks
|
||||
│ ├── notes.org ← deep implementation notes
|
||||
│ ├── suggestions.org ← pattern reference (not exported)
|
||||
│ └── images/ ← diagrams, screenshots
|
||||
└── dsa/
|
||||
├── arrays-hashing/
|
||||
│ ├── 0217-contains-duplicate.org
|
||||
@@ -48,12 +58,14 @@ org/study_deck_02/
|
||||
|
||||
18 topics, 199 problems (NeetCode 150).
|
||||
|
||||
## The `#+PROPERTY: STUDY_DECK_02` Header
|
||||
## The `#+ANKI_DECK: study_deck_02` Header
|
||||
|
||||
Every `.org` file in this deck has `#+PROPERTY: STUDY_DECK_02` at the
|
||||
Every `.org` file in this deck has `#+ANKI_DECK: study_deck_02` at the
|
||||
top. This tells org-anki which Anki deck to export into. Without it,
|
||||
the file won't be picked up by the exporter.
|
||||
|
||||
To override per-card, use `:ANKI_DECK:` in the properties drawer.
|
||||
|
||||
## Roadmap Format
|
||||
|
||||
Each problem in roadmap.org uses a properties drawer to keep links tidy:
|
||||
@@ -78,7 +90,7 @@ Each problem note links back to the roadmap via the `NEETCODE` property:
|
||||
|
||||
```org
|
||||
* TODO 0217. Contains Duplicate :easy:
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[../../roadmap.org::*0217. Contains Duplicate][Roadmap]]
|
||||
:END:
|
||||
@@ -121,3 +133,14 @@ This deck starts with NeetCode 150. To add more:
|
||||
header. They'll all export to the same Anki deck.
|
||||
- **Flashcards** — add `** Front` / `** Back` sections to any note
|
||||
for Anki-style cards (see root `AGENTS.md` for format).
|
||||
|
||||
## Backlinking Convention
|
||||
|
||||
Every `.org` file should link back to `roadmap.org` via a property:
|
||||
|
||||
- Problem notes use `:NEETCODE:` linking to the roadmap heading
|
||||
- Toolkit/tricks use `:ROADMAP:` linking to a relevant problem
|
||||
- Roadmap entries use `:TRICK:` linking to relevant tricks
|
||||
|
||||
This keeps the web of links navigable in both directions — from
|
||||
roadmap to notes, from notes to tricks, and tricks back to problems.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Add :lc-problem <number> to org source blocks in leetcode problem files."""
|
||||
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def process_file(path: Path, dry_run: bool = False) -> bool:
|
||||
"""Add :lc-problem to src blocks that don't already have it. Returns True if modified."""
|
||||
m = re.match(r"(\d{4})-", path.stem)
|
||||
if not m:
|
||||
return False
|
||||
problem_num = str(int(m.group(1))) # strip leading zeros: "0015" -> "15"
|
||||
|
||||
text = path.read_text()
|
||||
original = text
|
||||
|
||||
# Match #+begin_src <lang> where lang is python or cpp
|
||||
def fix_src_block(match: re.Match) -> str:
|
||||
full = match.group(0)
|
||||
lang = match.group(1)
|
||||
suffix = match.group(2) or ""
|
||||
|
||||
# If already has :lc-problem, fix leading zeros
|
||||
if ":lc-problem" in suffix:
|
||||
suffix = re.sub(r":lc-problem 0+(\d)", rf":lc-problem \1", suffix)
|
||||
return f"#+begin_src {lang}{suffix}"
|
||||
|
||||
# Add :lc-problem
|
||||
extra = f" :lc-problem {problem_num}"
|
||||
if lang == "python":
|
||||
extra += " :lc-lang python3"
|
||||
return f"#+begin_src {lang}{extra}{suffix}"
|
||||
|
||||
text = re.sub(
|
||||
r"#\+begin_src (python|cpp)([^\n]*)",
|
||||
fix_src_block,
|
||||
text,
|
||||
)
|
||||
|
||||
if text != original:
|
||||
if dry_run:
|
||||
print(f" would modify: {path.name}")
|
||||
else:
|
||||
path.write_text(text)
|
||||
print(f" modified: {path.name}")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
dry_run = "--dry-run" in sys.argv
|
||||
base = Path(__file__).parent / "dsa"
|
||||
if not base.exists():
|
||||
print(f"dsa/ directory not found at {base}")
|
||||
sys.exit(1)
|
||||
|
||||
org_files = sorted(base.rglob("*.org"))
|
||||
print(f"Found {len(org_files)} org files in dsa/")
|
||||
|
||||
modified = 0
|
||||
skipped = 0
|
||||
for f in org_files:
|
||||
if process_file(f, dry_run):
|
||||
modified += 1
|
||||
else:
|
||||
skipped += 1
|
||||
|
||||
print(f"\nDone: {modified} modified, {skipped} unchanged")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0005. Longest Palindromic Substring :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0005. Longest Palindromic Substring][0005. Longest Palindromic Substring]]
|
||||
@@ -35,13 +35,13 @@ Output: "bb"
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 5 :lc-lang python3
|
||||
class Solution:
|
||||
def longestPalindrome(self, s: str) -> str:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 5
|
||||
class Solution {
|
||||
public:
|
||||
string longestPalindrome(string s) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0070. Climbing Stairs :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0070. Climbing Stairs][0070. Climbing Stairs]]
|
||||
@@ -41,13 +41,13 @@ Explanation: There are three ways to climb to the top.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 70 :lc-lang python3
|
||||
class Solution:
|
||||
def climbStairs(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 70
|
||||
class Solution {
|
||||
public:
|
||||
int climbStairs(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0091. Decode Ways :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0091. Decode Ways][0091. Decode Ways]]
|
||||
@@ -72,13 +72,13 @@ The test cases are generated so that the answer fits in a *32-bit* integer.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 91 :lc-lang python3
|
||||
class Solution:
|
||||
def numDecodings(self, s: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 91
|
||||
class Solution {
|
||||
public:
|
||||
int numDecodings(string s) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0139. Word Break :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0139. Word Break][0139. Word Break]]
|
||||
@@ -54,13 +54,13 @@ Output: false
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 139 :lc-lang python3
|
||||
class Solution:
|
||||
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 139
|
||||
class Solution {
|
||||
public:
|
||||
bool wordBreak(string s, vector<string>& wordDict) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0152. Maximum Product Subarray :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0152. Maximum Product Subarray][0152. Maximum Product Subarray]]
|
||||
@@ -42,13 +42,13 @@ Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 152 :lc-lang python3
|
||||
class Solution:
|
||||
def maxProduct(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 152
|
||||
class Solution {
|
||||
public:
|
||||
int maxProduct(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0198. House Robber :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0198. House Robber][0198. House Robber]]
|
||||
@@ -40,13 +40,13 @@ Total amount you can rob = 2 + 9 + 1 = 12.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 198 :lc-lang python3
|
||||
class Solution:
|
||||
def rob(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 198
|
||||
class Solution {
|
||||
public:
|
||||
int rob(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0213. House Robber II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0213. House Robber II][0213. House Robber II]]
|
||||
@@ -48,13 +48,13 @@ Output: 3
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 213 :lc-lang python3
|
||||
class Solution:
|
||||
def rob(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 213
|
||||
class Solution {
|
||||
public:
|
||||
int rob(vector<int>& nums) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0300. Longest Increasing Subsequence :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0300. Longest Increasing Subsequence][0300. Longest Increasing Subsequence]]
|
||||
@@ -46,13 +46,13 @@ Follow up: Can you come up with an algorithm that runs in ~O(n log(n))~ time com
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 300 :lc-lang python3
|
||||
class Solution:
|
||||
def lengthOfLIS(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 300
|
||||
class Solution {
|
||||
public:
|
||||
int lengthOfLIS(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0322. Coin Change :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0322. Coin Change][0322. Coin Change]]
|
||||
@@ -50,13 +50,13 @@ Output: 0
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 322 :lc-lang python3
|
||||
class Solution:
|
||||
def coinChange(self, coins: List[int], amount: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 322
|
||||
class Solution {
|
||||
public:
|
||||
int coinChange(vector<int>& coins, int amount) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0416. Partition Equal Subset Sum :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0416. Partition Equal Subset Sum][0416. Partition Equal Subset Sum]]
|
||||
@@ -36,13 +36,13 @@ Explanation: The array cannot be partitioned into equal sum subsets.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 416 :lc-lang python3
|
||||
class Solution:
|
||||
def canPartition(self, nums: List[int]) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 416
|
||||
class Solution {
|
||||
public:
|
||||
bool canPartition(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0647. Palindromic Substrings :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0647. Palindromic Substrings][0647. Palindromic Substrings]]
|
||||
@@ -40,13 +40,13 @@ Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 647 :lc-lang python3
|
||||
class Solution:
|
||||
def countSubstrings(self, s: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 647
|
||||
class Solution {
|
||||
public:
|
||||
int countSubstrings(string s) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0656. Coin Path :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0656. Coin Path][0656. Coin Path]]
|
||||
@@ -8,11 +8,11 @@
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 656 :lc-lang python3
|
||||
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 656
|
||||
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0746. Min Cost Climbing Stairs :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0746. Min Cost Climbing Stairs][0746. Min Cost Climbing Stairs]]
|
||||
@@ -49,13 +49,13 @@ The total cost is 6.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 746 :lc-lang python3
|
||||
class Solution:
|
||||
def minCostClimbingStairs(self, cost: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 746
|
||||
class Solution {
|
||||
public:
|
||||
int minCostClimbingStairs(vector<int>& cost) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0010. Regular Expression Matching :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0010. Regular Expression Matching][0010. Regular Expression Matching]]
|
||||
@@ -58,13 +58,13 @@ Explanation: ".*" means "zero or more (*) of any character (.)".
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 10 :lc-lang python3
|
||||
class Solution:
|
||||
def isMatch(self, s: str, p: str) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 10
|
||||
class Solution {
|
||||
public:
|
||||
bool isMatch(string s, string p) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0062. Unique Paths :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0062. Unique Paths][0062. Unique Paths]]
|
||||
@@ -40,13 +40,13 @@ Explanation: From the top-left corner, there are a total of 3 ways to reach the
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 62 :lc-lang python3
|
||||
class Solution:
|
||||
def uniquePaths(self, m: int, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 62
|
||||
class Solution {
|
||||
public:
|
||||
int uniquePaths(int m, int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0072. Edit Distance :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0072. Edit Distance][0072. Edit Distance]]
|
||||
@@ -52,13 +52,13 @@ exection -> execution (insert 'u')
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 72 :lc-lang python3
|
||||
class Solution:
|
||||
def minDistance(self, word1: str, word2: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 72
|
||||
class Solution {
|
||||
public:
|
||||
int minDistance(string word1, string word2) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0097. Interleaving String :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0097. Interleaving String][0097. Interleaving String]]
|
||||
@@ -64,13 +64,13 @@ Output: true
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 97 :lc-lang python3
|
||||
class Solution:
|
||||
def isInterleave(self, s1: str, s2: str, s3: str) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 97
|
||||
class Solution {
|
||||
public:
|
||||
bool isInterleave(string s1, string s2, string s3) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0115. Distinct Subsequences :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0115. Distinct Subsequences][0115. Distinct Subsequences]]
|
||||
@@ -48,13 +48,13 @@ babgbag
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 115 :lc-lang python3
|
||||
class Solution:
|
||||
def numDistinct(self, s: str, t: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 115
|
||||
class Solution {
|
||||
public:
|
||||
int numDistinct(string s, string t) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0309. Best Time to Buy And Sell Stock With Cooldown :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0309. Best Time to Buy And Sell Stock With Cooldown][0309. Best Time to Buy And Sell Stock With Cooldown]]
|
||||
@@ -41,13 +41,13 @@ Output: 0
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 309 :lc-lang python3
|
||||
class Solution:
|
||||
def maxProfit(self, prices: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 309
|
||||
class Solution {
|
||||
public:
|
||||
int maxProfit(vector<int>& prices) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0312. Burst Balloons :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0312. Burst Balloons][0312. Burst Balloons]]
|
||||
@@ -43,13 +43,13 @@ Output: 10
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 312 :lc-lang python3
|
||||
class Solution:
|
||||
def maxCoins(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 312
|
||||
class Solution {
|
||||
public:
|
||||
int maxCoins(vector<int>& nums) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0329. Longest Increasing Path In a Matrix :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0329. Longest Increasing Path In a Matrix][0329. Longest Increasing Path In a Matrix]]
|
||||
@@ -51,13 +51,13 @@ Output: 1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 329 :lc-lang python3
|
||||
class Solution:
|
||||
def longestIncreasingPath(self, matrix: List[List[int]]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 329
|
||||
class Solution {
|
||||
public:
|
||||
int longestIncreasingPath(vector<vector<int>>& matrix) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0494. Target Sum :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0494. Target Sum][0494. Target Sum]]
|
||||
@@ -50,13 +50,13 @@ Output: 1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 494 :lc-lang python3
|
||||
class Solution:
|
||||
def findTargetSumWays(self, nums: List[int], target: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 494
|
||||
class Solution {
|
||||
public:
|
||||
int findTargetSumWays(vector<int>& nums, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0518. Coin Change II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0518. Coin Change II][0518. Coin Change II]]
|
||||
@@ -59,13 +59,13 @@ Output: 1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 518 :lc-lang python3
|
||||
class Solution:
|
||||
def change(self, amount: int, coins: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 518
|
||||
class Solution {
|
||||
public:
|
||||
int change(int amount, vector<int>& coins) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1143. Longest Common Subsequence :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1143. Longest Common Subsequence][1143. Longest Common Subsequence]]
|
||||
@@ -52,13 +52,13 @@ Explanation: There is no such common subsequence, so the result is 0.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1143 :lc-lang python3
|
||||
class Solution:
|
||||
def longestCommonSubsequence(self, text1: str, text2: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1143
|
||||
class Solution {
|
||||
public:
|
||||
int longestCommonSubsequence(string text1, string text2) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1220. Count Vowels Permutation :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1220. Count Vowels Permutation][1220. Count Vowels Permutation]]
|
||||
@@ -57,13 +57,13 @@ Output: 68
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1220 :lc-lang python3
|
||||
class Solution:
|
||||
def countVowelPermutation(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1220
|
||||
class Solution {
|
||||
public:
|
||||
int countVowelPermutation(int n) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1911. Maximum Alternating Subsequence Sum :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1911. Maximum Alternating Subsequence Sum][1911. Maximum Alternating Subsequence Sum]]
|
||||
@@ -52,13 +52,13 @@ Explanation: It is optimal to choose the subsequence [6,1,5] with alternating su
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1911 :lc-lang python3
|
||||
class Solution:
|
||||
def maxAlternatingSum(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1911
|
||||
class Solution {
|
||||
public:
|
||||
long long maxAlternatingSum(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0269. Alien Dictionary :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0269. Alien Dictionary][0269. Alien Dictionary]]
|
||||
@@ -8,11 +8,11 @@
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 269 :lc-lang python3
|
||||
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 269
|
||||
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0332. Reconstruct Itinerary :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0332. Reconstruct Itinerary][0332. Reconstruct Itinerary]]
|
||||
@@ -49,13 +49,13 @@ Explanation: Another possible reconstruction is ["JFK","SFO","ATL","JFK","ATL","
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 332 :lc-lang python3
|
||||
class Solution:
|
||||
def findItinerary(self, tickets: List[List[str]]) -> List[str]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 332
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> findItinerary(vector<vector<string>>& tickets) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0743. Network Delay Time :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0743. Network Delay Time][0743. Network Delay Time]]
|
||||
@@ -55,13 +55,13 @@ Output: -1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 743 :lc-lang python3
|
||||
class Solution:
|
||||
def networkDelayTime(self, times: List[List[int]], n: int, k: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 743
|
||||
class Solution {
|
||||
public:
|
||||
int networkDelayTime(vector<vector<int>>& times, int n, int k) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0778. Swim In Rising Water :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0778. Swim In Rising Water][0778. Swim In Rising Water]]
|
||||
@@ -53,13 +53,13 @@ We need to wait until time 16 so that (0, 0) and (4, 4) are connected.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 778 :lc-lang python3
|
||||
class Solution:
|
||||
def swimInWater(self, grid: List[List[int]]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 778
|
||||
class Solution {
|
||||
public:
|
||||
int swimInWater(vector<vector<int>>& grid) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0787. Cheapest Flights Within K Stops :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0787. Cheapest Flights Within K Stops][0787. Cheapest Flights Within K Stops]]
|
||||
@@ -69,13 +69,13 @@ The optimal path with no stops from city 0 to 2 is marked in red and has cost 50
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 787 :lc-lang python3
|
||||
class Solution:
|
||||
def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 787
|
||||
class Solution {
|
||||
public:
|
||||
int findCheapestPrice(int n, vector<vector<int>>& flights, int src, int dst, int k) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1584. Min Cost to Connect All Points :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1584. Min Cost to Connect All Points][1584. Min Cost to Connect All Points]]
|
||||
@@ -44,13 +44,13 @@ Output: 18
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1584 :lc-lang python3
|
||||
class Solution:
|
||||
def minCostConnectPoints(self, points: List[List[int]]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1584
|
||||
class Solution {
|
||||
public:
|
||||
int minCostConnectPoints(vector<vector<int>>& points) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 2493. Divide Nodes Into the Maximum Number of Groups :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*2493. Divide Nodes Into the Maximum Number of Groups][2493. Divide Nodes Into the Maximum Number of Groups]]
|
||||
@@ -61,13 +61,13 @@ It can be shown that no grouping is possible.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 2493 :lc-lang python3
|
||||
class Solution:
|
||||
def magnificentSets(self, n: int, edges: List[List[int]]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 2493
|
||||
class Solution {
|
||||
public:
|
||||
int magnificentSets(int n, vector<vector<int>>& edges) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 2812. Find the Safest Path in a Grid :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*2812. Find the Safest Path in a Grid][2812. Find the Safest Path in a Grid]]
|
||||
@@ -69,13 +69,13 @@ It can be shown that there are no other paths with a higher safeness factor.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 2812 :lc-lang python3
|
||||
class Solution:
|
||||
def maximumSafenessFactor(self, grid: List[List[int]]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 2812
|
||||
class Solution {
|
||||
public:
|
||||
int maximumSafenessFactor(vector<vector<int>>& grid) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0001. Two Sum :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0001. Two Sum][0001. Two Sum]]
|
||||
@@ -54,17 +54,40 @@ Output: [0,1]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1 :lc-lang python3
|
||||
class Solution:
|
||||
def twoSum(self, nums: List[int], target: int) -> List[int]:
|
||||
sb = {}
|
||||
for xi, x in enumerate(nums):
|
||||
want = target - x;
|
||||
if want in sb:
|
||||
return sb[want], xi
|
||||
sb[x] = xi
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1
|
||||
#include <algorithm>
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> twoSum(vector<int>& nums, int target) {
|
||||
|
||||
vector<int> twoSum(vector<int>& nums, int target) {
|
||||
std::sort(nums.begin(), nums.end());
|
||||
for (int i=0; i< nums.size(); i++) {
|
||||
int x = nums[i];
|
||||
if (x > target) {
|
||||
return {};
|
||||
}
|
||||
// TODO: c++ binary search, i forgot how to do this
|
||||
int want = target - x
|
||||
auto it = std::binary_learch(nums.begin() + i + 1, nums.end(), want);
|
||||
if (it != nums.end() && *it == want) {
|
||||
int wi = std::distance(nums.begin(), it)
|
||||
return {i, wi}
|
||||
}
|
||||
}
|
||||
reuturn {};
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0036. Valid Sudoku :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0036. Valid Sudoku][0036. Valid Sudoku]]
|
||||
@@ -67,13 +67,13 @@ Explanation: Same as Example 1, except with the 5 in the top left corner being m
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 36 :lc-lang python3
|
||||
class Solution:
|
||||
def isValidSudoku(self, board: List[List[str]]) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 36
|
||||
class Solution {
|
||||
public:
|
||||
bool isValidSudoku(vector<vector<char>>& board) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0049. Group Anagrams :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0049. Group Anagrams][0049. Group Anagrams]]
|
||||
@@ -44,13 +44,13 @@ Given an array of strings ~strs~, group the anagrams together. You can return th
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 49 :lc-lang python3
|
||||
class Solution:
|
||||
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 49
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<string>> groupAnagrams(vector<string>& strs) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0128. Longest Consecutive Sequence :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0128. Longest Consecutive Sequence][0128. Longest Consecutive Sequence]]
|
||||
@@ -46,13 +46,13 @@ Output: 3
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 128 :lc-lang python3
|
||||
class Solution:
|
||||
def longestConsecutive(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 128
|
||||
class Solution {
|
||||
public:
|
||||
int longestConsecutive(vector<int>& nums) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0217. Contains Duplicate :easy:
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* DONE 0217. Contains Duplicate :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0217. Contains Duplicate][0217. Contains Duplicate]]
|
||||
:END:
|
||||
@@ -38,21 +38,36 @@ All elements are distinct.
|
||||
|
||||
- ~-10^{9} <= nums[i] <= 10^{9}~
|
||||
|
||||
** TODO Approach
|
||||
** DONE Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
** DONE Python
|
||||
#+begin_src python :lc-problem 217 :lc-lang python3
|
||||
class Solution:
|
||||
def containsDuplicate(self, nums: List[int]) -> bool:
|
||||
s = set()
|
||||
for x in nums:
|
||||
if x in s:
|
||||
return True
|
||||
s.add(x)
|
||||
return False
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
** DONE C++
|
||||
#+begin_src cpp :lc-problem 217
|
||||
#include <vector>
|
||||
#include <set>
|
||||
class Solution {
|
||||
public:
|
||||
bool containsDuplicate(vector<int>& nums) {
|
||||
|
||||
bool containsDuplicate(std::vector<int>& nums) {
|
||||
std::set<int> s;
|
||||
for (int x: nums) {
|
||||
if (s.contains(x)) {
|
||||
return true;
|
||||
}
|
||||
s.insert(x);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0238. Product of Array Except Self :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0238. Product of Array Except Self][0238. Product of Array Except Self]]
|
||||
@@ -40,13 +40,13 @@ Output: [0,0,9,0,0]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 238 :lc-lang python3
|
||||
class Solution:
|
||||
def productExceptSelf(self, nums: List[int]) -> List[int]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 238
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> productExceptSelf(vector<int>& nums) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0242. Valid Anagram :easy:
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* DONE 0242. Valid Anagram :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0242. Valid Anagram][0242. Valid Anagram]]
|
||||
:END:
|
||||
@@ -26,21 +26,36 @@ Given two strings ~s~ and ~t~, return ~true~ if ~t~ is an anagram of ~s~, and ~f
|
||||
|
||||
*Follow up:* What if the inputs contain Unicode characters? How would you adapt your solution to such a case?
|
||||
|
||||
** TODO Approach
|
||||
** DONE Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
** DONE Python
|
||||
#+begin_src python :lc-problem 242 :lc-lang python3
|
||||
class Solution:
|
||||
def isAnagram(self, s: str, t: str) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
** DONE C++
|
||||
#+begin_src cpp :lc-problem 242
|
||||
#include <map>
|
||||
#include <string>
|
||||
class Solution {
|
||||
public:
|
||||
bool isAnagram(string s, string t) {
|
||||
|
||||
bool isAnagram(std::string s, std::string t) {
|
||||
std::map<char, int> ctr;
|
||||
for (char c: s) {
|
||||
ctr[c] += c;
|
||||
}
|
||||
for (char c: t) {
|
||||
if (ctr[c] == 0) {
|
||||
return false;
|
||||
}
|
||||
ctr[c] -= 1;
|
||||
if (ctr[c] == 0) {
|
||||
ctr.erase(c);
|
||||
}
|
||||
}
|
||||
return ctr.size() == 0;
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0271. Encode and Decode Strings :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0271. Encode and Decode Strings][0271. Encode and Decode Strings]]
|
||||
@@ -8,11 +8,11 @@
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 271 :lc-lang python3
|
||||
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 271
|
||||
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0347. Top K Frequent Elements :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0347. Top K Frequent Elements][0347. Top K Frequent Elements]]
|
||||
@@ -40,13 +40,15 @@ Given an integer array ~nums~ and an integer ~k~, return /the/ ~k~ /most frequen
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 347 :lc-lang python3
|
||||
class Solution:
|
||||
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
|
||||
from collections import Counter
|
||||
return [n for n, _ in Counter(nums).most_common(k)]
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 347
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> topKFrequent(vector<int>& nums, int k) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1408. String Matching in an Array :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1408. String Matching in an Array][1408. String Matching in an Array]]
|
||||
@@ -51,13 +51,43 @@ Explanation: No string of words is substring of another string.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1408 :lc-lang python3
|
||||
from collections import defaultdict as dd
|
||||
class Solution:
|
||||
def stringMatching(self, words: List[str]) -> List[str]:
|
||||
words = reversed(sorted(words))
|
||||
def squash(word, trie):
|
||||
lst = []
|
||||
for c in word:
|
||||
lst.append([trie, ''])
|
||||
for i in range(len(lst)):
|
||||
lst[i][0] = lst[i][0][c]
|
||||
lst[i][1] += c
|
||||
if not lst[i][0]['ads']:
|
||||
lst[i][0]['ads'] = {lst[i][1]: [word]}
|
||||
else:
|
||||
lst[i][0]['ads'][lst[i][1]].append(word)
|
||||
def in_trie(word, trie):
|
||||
for c in word:
|
||||
if c not in trie:
|
||||
return []
|
||||
trie = trie[c]
|
||||
return [(word, bw) for bw in trie['ads'][word]]
|
||||
trie_maker = lambda: dd(trie_maker)
|
||||
trie = trie_maker()
|
||||
ans = []
|
||||
for s in words:
|
||||
ans += in_trie(s, trie)
|
||||
squash(s, trie)
|
||||
return ans
|
||||
|
||||
|
||||
#+end_src
|
||||
|
||||
**
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1408
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> stringMatching(vector<string>& words) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1769. Minimum Number of Operations to Move All Balls to Each Box :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1769. Minimum Number of Operations to Move All Balls to Each Box][1769. Minimum Number of Operations to Move All Balls to Each Box]]
|
||||
@@ -46,13 +46,13 @@ Output: [11,8,5,4,3,4]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1769 :lc-lang python3
|
||||
class Solution:
|
||||
def minOperations(self, boxes: str) -> List[int]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1769
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> minOperations(string boxes) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 2678. Number of Senior Citizens :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*2678. Number of Senior Citizens][2678. Number of Senior Citizens]]
|
||||
@@ -52,13 +52,13 @@ Explanation: None of the passengers are older than 60.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 2678 :lc-lang python3
|
||||
class Solution:
|
||||
def countSeniors(self, details: List[str]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 2678
|
||||
class Solution {
|
||||
public:
|
||||
int countSeniors(vector<string>& details) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0017. Letter Combinations of a Phone Number :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0017. Letter Combinations of a Phone Number][0017. Letter Combinations of a Phone Number]]
|
||||
@@ -36,13 +36,13 @@ Output: ["a","b","c"]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 17 :lc-lang python3
|
||||
class Solution:
|
||||
def letterCombinations(self, digits: str) -> List[str]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 17
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> letterCombinations(string digits) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0022. Generate Parentheses :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0022. Generate Parentheses][0022. Generate Parentheses]]
|
||||
@@ -30,13 +30,13 @@ Output: ["()"]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 22 :lc-lang python3
|
||||
class Solution:
|
||||
def generateParenthesis(self, n: int) -> List[str]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 22
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> generateParenthesis(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0039. Combination Sum :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0039. Combination Sum][0039. Combination Sum]]
|
||||
@@ -55,13 +55,13 @@ Output: []
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 39 :lc-lang python3
|
||||
class Solution:
|
||||
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 39
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0040. Combination Sum II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0040. Combination Sum II][0040. Combination Sum II]]
|
||||
@@ -50,13 +50,13 @@ Output:
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 40 :lc-lang python3
|
||||
class Solution:
|
||||
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 40
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0046. Permutations :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0046. Permutations][0046. Permutations]]
|
||||
@@ -41,13 +41,13 @@ Output: [[1]]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 46 :lc-lang python3
|
||||
class Solution:
|
||||
def permute(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 46
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> permute(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0051. N Queens :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0051. N Queens][0051. N Queens]]
|
||||
@@ -37,13 +37,13 @@ Output: [["Q"]]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 51 :lc-lang python3
|
||||
class Solution:
|
||||
def solveNQueens(self, n: int) -> List[List[str]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 51
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<string>> solveNQueens(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0052. N Queens II :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0052. N Queens II][0052. N Queens II]]
|
||||
@@ -35,13 +35,13 @@ Output: 1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 52 :lc-lang python3
|
||||
class Solution:
|
||||
def totalNQueens(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 52
|
||||
class Solution {
|
||||
public:
|
||||
int totalNQueens(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0077. Combinations :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0077. Combinations][0077. Combinations]]
|
||||
@@ -39,13 +39,13 @@ Explanation: There is 1 choose 1 = 1 total combination.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 77 :lc-lang python3
|
||||
class Solution:
|
||||
def combine(self, n: int, k: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 77
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combine(int n, int k) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0078. Subsets :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0078. Subsets][0078. Subsets]]
|
||||
@@ -38,13 +38,13 @@ Output: [[],[0]]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 78 :lc-lang python3
|
||||
class Solution:
|
||||
def subsets(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 78
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> subsets(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0079. Word Search :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0079. Word Search][0079. Word Search]]
|
||||
@@ -53,13 +53,13 @@ Output: false
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 79 :lc-lang python3
|
||||
class Solution:
|
||||
def exist(self, board: List[List[str]], word: str) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 79
|
||||
class Solution {
|
||||
public:
|
||||
bool exist(vector<vector<char>>& board, string word) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0090. Subsets II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0090. Subsets II][0090. Subsets II]]
|
||||
@@ -34,13 +34,13 @@ Output: [[],[0]]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 90 :lc-lang python3
|
||||
class Solution:
|
||||
def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 90
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> subsetsWithDup(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0131. Palindrome Partitioning :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0131. Palindrome Partitioning][0131. Palindrome Partitioning]]
|
||||
@@ -32,13 +32,13 @@ Output: [["a"]]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 131 :lc-lang python3
|
||||
class Solution:
|
||||
def partition(self, s: str) -> List[List[str]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 131
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<string>> partition(string s) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0351. Android Unlock Patterns :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0351. Android Unlock Patterns][0351. Android Unlock Patterns]]
|
||||
@@ -8,11 +8,11 @@
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 351 :lc-lang python3
|
||||
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 351
|
||||
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1079. Letter Tile Possibilities :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1079. Letter Tile Possibilities][1079. Letter Tile Possibilities]]
|
||||
@@ -46,13 +46,13 @@ Output: 1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1079 :lc-lang python3
|
||||
class Solution:
|
||||
def numTilePossibilities(self, tiles: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1079
|
||||
class Solution {
|
||||
public:
|
||||
int numTilePossibilities(string tiles) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 1863. Sum of All Subsets XOR Total :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1863. Sum of All Subsets XOR Total][Roadmap]]
|
||||
@@ -8,11 +8,11 @@
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 1863 :lc-lang python3
|
||||
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 1863
|
||||
|
||||
#+end_src
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0004. Median of Two Sorted Arrays :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0004. Median of Two Sorted Arrays][0004. Median of Two Sorted Arrays]]
|
||||
@@ -46,13 +46,13 @@ Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 4 :lc-lang python3
|
||||
class Solution:
|
||||
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 4
|
||||
class Solution {
|
||||
public:
|
||||
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0033. Search In Rotated Sorted Array :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0033. Search In Rotated Sorted Array][0033. Search In Rotated Sorted Array]]
|
||||
@@ -51,13 +51,13 @@ Output: -1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 33 :lc-lang python3
|
||||
class Solution:
|
||||
def search(self, nums: List[int], target: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 33
|
||||
class Solution {
|
||||
public:
|
||||
int search(vector<int>& nums, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0074. Search a 2D Matrix :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0074. Search a 2D Matrix][0074. Search a 2D Matrix]]
|
||||
@@ -46,13 +46,13 @@ Output: false
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 74 :lc-lang python3
|
||||
class Solution:
|
||||
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 74
|
||||
class Solution {
|
||||
public:
|
||||
bool searchMatrix(vector<vector<int>>& matrix, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0153. Find Minimum In Rotated Sorted Array :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0153. Find Minimum In Rotated Sorted Array][0153. Find Minimum In Rotated Sorted Array]]
|
||||
@@ -62,13 +62,13 @@ Explanation: The original array was [11,13,15,17] and it was rotated 4 times.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 153 :lc-lang python3
|
||||
class Solution:
|
||||
def findMin(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 153
|
||||
class Solution {
|
||||
public:
|
||||
int findMin(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0704. Binary Search :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0704. Binary Search][0704. Binary Search]]
|
||||
@@ -42,13 +42,13 @@ Explanation: 2 does not exist in nums so return -1
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 704 :lc-lang python3
|
||||
class Solution:
|
||||
def search(self, nums: List[int], target: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 704
|
||||
class Solution {
|
||||
public:
|
||||
int search(vector<int>& nums, int target) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0719. Find K-th Smallest Pair Distance :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0719. Find K-th Smallest Pair Distance][0719. Find K-th Smallest Pair Distance]]
|
||||
@@ -54,13 +54,13 @@ Output: 5
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 719 :lc-lang python3
|
||||
class Solution:
|
||||
def smallestDistancePair(self, nums: List[int], k: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 719
|
||||
class Solution {
|
||||
public:
|
||||
int smallestDistancePair(vector<int>& nums, int k) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0875. Koko Eating Bananas :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0875. Koko Eating Bananas][0875. Koko Eating Bananas]]
|
||||
@@ -51,13 +51,13 @@ Output: 23
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 875 :lc-lang python3
|
||||
class Solution:
|
||||
def minEatingSpeed(self, piles: List[int], h: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 875
|
||||
class Solution {
|
||||
public:
|
||||
int minEatingSpeed(vector<int>& piles, int h) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0981. Time Based Key Value Store :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0981. Time Based Key Value Store][0981. Time Based Key Value Store]]
|
||||
@@ -51,7 +51,7 @@ timeMap.get("foo", 5); // return "bar2"
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 981 :lc-lang python3
|
||||
class TimeMap:
|
||||
|
||||
def __init__(self):
|
||||
@@ -71,7 +71,7 @@ class TimeMap:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 981
|
||||
class TimeMap {
|
||||
public:
|
||||
TimeMap() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 2300. Successful Pairs of Spells and Potions :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*2300. Successful Pairs of Spells and Potions][2300. Successful Pairs of Spells and Potions]]
|
||||
@@ -54,13 +54,13 @@ Thus, [2,0,2] is returned.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 2300 :lc-lang python3
|
||||
class Solution:
|
||||
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 2300
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* When to use lower_bound vs binary_search :cpp:binary-search:algorithm:retrieval::recognition:
|
||||
:PROPERTIES:
|
||||
:END:
|
||||
|
||||
** Front
|
||||
When should you use ~std::lower_bound~ instead of ~std::binary_search~?
|
||||
|
||||
** Back
|
||||
Use ~lower_bound~ when you need the *position/index* of the element.
|
||||
Use ~binary_search~ when you only need to know *if it exists* (bool).
|
||||
@@ -0,0 +1,10 @@
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* Two Sum gotcha: sorting destroys original indices :cpp:two-sum:binary-search:retrieval::recognition:
|
||||
:PROPERTIES:
|
||||
:END:
|
||||
|
||||
** Front
|
||||
If you sort ~nums~ in-place for Two Sum, what goes wrong?
|
||||
|
||||
** Back
|
||||
Sorting changes the indices. If the problem requires returning *original* indices, store ~{value, original_index}~ pairs before sorting.
|
||||
@@ -0,0 +1,14 @@
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* std::binary_search: check element exists :cpp:binary-search:algorithm:retrieval::recognition:
|
||||
:PROPERTIES:
|
||||
:END:
|
||||
|
||||
** Front
|
||||
What does ~std::binary_search~ return, and what must the range be?
|
||||
|
||||
** Back
|
||||
Returns ~bool~ (true if element found). The range must be *sorted*.
|
||||
|
||||
#+begin_src cpp
|
||||
bool found = std::binary_search(vec.begin(), vec.end(), value);
|
||||
#+end_src
|
||||
@@ -0,0 +1,14 @@
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* std::lower_bound: find position of element :cpp:binary-search:algorithm:retrieval::recognition:
|
||||
:PROPERTIES:
|
||||
:END:
|
||||
|
||||
** Front
|
||||
What does ~std::lower_bound~ return?
|
||||
|
||||
** Back
|
||||
An iterator to the first element *>=* the given value. Returns ~end()~ if no such element exists.
|
||||
|
||||
#+begin_src cpp
|
||||
auto it = std::lower_bound(vec.begin(), vec.end(), value);
|
||||
#+end_src
|
||||
@@ -0,0 +1,16 @@
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* Task: Two Sum complement lookup with lower_bound :cpp:binary-search:two-sum:retrieval::production:
|
||||
:PROPERTIES:
|
||||
:END:
|
||||
|
||||
** Front
|
||||
Given sorted ~nums~ and index ~i~, write C++ to check if ~target - nums[i]~ exists in the rest of the array using ~std::lower_bound~.
|
||||
|
||||
** Back
|
||||
#+begin_src cpp
|
||||
int complement = target - nums[i];
|
||||
auto it = std::lower_bound(nums.begin() + i + 1, nums.end(), complement);
|
||||
if (it != nums.end() && *it == complement) {
|
||||
return {(int)i, (int)std::distance(nums.begin(), it)};
|
||||
}
|
||||
#+end_src
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0007. Reverse Integer :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0007. Reverse Integer][0007. Reverse Integer]]
|
||||
@@ -43,13 +43,13 @@ Output: 21
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 7 :lc-lang python3
|
||||
class Solution:
|
||||
def reverse(self, x: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 7
|
||||
class Solution {
|
||||
public:
|
||||
int reverse(int x) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0136. Single Number :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0136. Single Number][0136. Single Number]]
|
||||
@@ -38,13 +38,13 @@ You must implement a solution with a linear runtime complexity and use only cons
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 136 :lc-lang python3
|
||||
class Solution:
|
||||
def singleNumber(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 136
|
||||
class Solution {
|
||||
public:
|
||||
int singleNumber(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0190. Reverse Bits :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0190. Reverse Bits][0190. Reverse Bits]]
|
||||
@@ -52,13 +52,13 @@ Reverse bits of a given 32 bits signed integer.
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 190 :lc-lang python3
|
||||
class Solution:
|
||||
def reverseBits(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 190
|
||||
class Solution {
|
||||
public:
|
||||
int reverseBits(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0191. Number of 1 Bits :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0191. Number of 1 Bits][0191. Number of 1 Bits]]
|
||||
@@ -46,13 +46,13 @@ The input binary string *1111111111111111111111111111101* has a total of thirty
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 191 :lc-lang python3
|
||||
class Solution:
|
||||
def hammingWeight(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 191
|
||||
class Solution {
|
||||
public:
|
||||
int hammingWeight(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0231. Power of Two :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0231. Power of Two][0231. Power of Two]]
|
||||
@@ -47,13 +47,13 @@ Output: false
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 231 :lc-lang python3
|
||||
class Solution:
|
||||
def isPowerOfTwo(self, n: int) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 231
|
||||
class Solution {
|
||||
public:
|
||||
bool isPowerOfTwo(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0260. Single Number III :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0260. Single Number III][0260. Single Number III]]
|
||||
@@ -48,13 +48,13 @@ Output: [1,0]
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 260 :lc-lang python3
|
||||
class Solution:
|
||||
def singleNumber(self, nums: List[int]) -> List[int]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 260
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> singleNumber(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0268. Missing Number :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0268. Missing Number][0268. Missing Number]]
|
||||
@@ -52,13 +52,13 @@ Given an array ~nums~ containing ~n~ distinct numbers in the range ~[0, n]~, ret
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 268 :lc-lang python3
|
||||
class Solution:
|
||||
def missingNumber(self, nums: List[int]) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 268
|
||||
class Solution {
|
||||
public:
|
||||
int missingNumber(vector<int>& nums) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0338. Counting Bits :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0338. Counting Bits][0338. Counting Bits]]
|
||||
@@ -49,13 +49,13 @@ Explanation:
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 338 :lc-lang python3
|
||||
class Solution:
|
||||
def countBits(self, n: int) -> List[int]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 338
|
||||
class Solution {
|
||||
public:
|
||||
vector<int> countBits(int n) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0371. Sum of Two Integers :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0371. Sum of Two Integers][0371. Sum of Two Integers]]
|
||||
@@ -30,13 +30,13 @@ Output: 5
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 371 :lc-lang python3
|
||||
class Solution:
|
||||
def getSum(self, a: int, b: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 371
|
||||
class Solution {
|
||||
public:
|
||||
int getSum(int a, int b) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 2220. Minimum Bit Flips to Convert Number :easy:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*2220. Minimum Bit Flips to Convert Number][2220. Minimum Bit Flips to Convert Number]]
|
||||
@@ -48,13 +48,13 @@ It can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
#+begin_src python :lc-problem 2220 :lc-lang python3
|
||||
class Solution:
|
||||
def minBitFlips(self, start: int, goal: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
#+begin_src cpp :lc-problem 2220
|
||||
class Solution {
|
||||
public:
|
||||
int minBitFlips(int start, int goal) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0127. Word Ladder :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0127. Word Ladder][0127. Word Ladder]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0130. Surrounded Regions :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0130. Surrounded Regions][0130. Surrounded Regions]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0133. Clone Graph :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0133. Clone Graph][0133. Clone Graph]]
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0200. Number of Islands :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0200. Number of Islands][0200. Number of Islands]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0207. Course Schedule :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0207. Course Schedule][0207. Course Schedule]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0210. Course Schedule II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0210. Course Schedule II][0210. Course Schedule II]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0261. Graph Valid Tree :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0261. Graph Valid Tree][0261. Graph Valid Tree]]
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0286. Walls And Gates :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0286. Walls And Gates][0286. Walls And Gates]]
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0323. Number of Connected Components In An Undirected Graph :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0323. Number of Connected Components In An Undirected Graph][0323. Number of Connected Components In An Undirected Graph]]
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0417. Pacific Atlantic Water Flow :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0417. Pacific Atlantic Water Flow][0417. Pacific Atlantic Water Flow]]
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
#+ANKI_DECK: study_deck_02
|
||||
* TODO 0684. Redundant Connection :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0684. Redundant Connection][0684. Redundant Connection]]
|
||||
@@ -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) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user