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,52 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0017. Letter Combinations of a Phone Number :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0017. Letter Combinations of a Phone Number][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0017. Letter Combinations of a Phone Number][0017. Letter Combinations of a Phone Number]]
|
||||
:END:
|
||||
|
||||
Given a string containing digits from ~2-9~ inclusive, return all possible letter combinations that the number could represent. Return the answer in *any order*.
|
||||
|
||||
A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: digits = "23"
|
||||
Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: digits = "2"
|
||||
Output: ["a","b","c"]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= digits.length <= 4~
|
||||
|
||||
- ~digits[i]~ is a digit in the range ~['2', '9']~.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def letterCombinations(self, digits: str) -> List[str]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> letterCombinations(string digits) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,46 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0022. Generate Parentheses :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0022. Generate Parentheses][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0022. Generate Parentheses][0022. Generate Parentheses]]
|
||||
:END:
|
||||
|
||||
Given ~n~ pairs of parentheses, write a function to /generate all combinations of well-formed parentheses/.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 3
|
||||
Output: ["((()))","(()())","(())()","()(())","()()()"]
|
||||
#+end_src
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 1
|
||||
Output: ["()"]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= n <= 8~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def generateParenthesis(self, n: int) -> List[str]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<string> generateParenthesis(int n) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,71 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0039. Combination Sum :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0039. Combination Sum][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0039. Combination Sum][0039. Combination Sum]]
|
||||
:END:
|
||||
|
||||
Given an array of *distinct* integers ~candidates~ and a target integer ~target~, return /a list of all *unique combinations* of /~candidates~/ where the chosen numbers sum to /~target~/./ You may return the combinations in *any order*.
|
||||
|
||||
The *same* number may be chosen from ~candidates~ an *unlimited number of times*. Two combinations are unique if the frequency of at least one of the chosen numbers is different.
|
||||
|
||||
The test cases are generated such that the number of unique combinations that sum up to ~target~ is less than ~150~ combinations for the given input.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: candidates = [2,3,6,7], target = 7
|
||||
Output: [[2,2,3],[7]]
|
||||
Explanation:
|
||||
2 and 3 are candidates, and 2 + 2 + 3 = 7. Note that 2 can be used multiple times.
|
||||
7 is a candidate, and 7 = 7.
|
||||
These are the only two combinations.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: candidates = [2,3,5], target = 8
|
||||
Output: [[2,2,2,2],[2,3,3],[3,5]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 3:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: candidates = [2], target = 1
|
||||
Output: []
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= candidates.length <= 30~
|
||||
|
||||
- ~2 <= candidates[i] <= 40~
|
||||
|
||||
- All elements of ~candidates~ are *distinct*.
|
||||
|
||||
- ~1 <= target <= 40~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,66 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0040. Combination Sum II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0040. Combination Sum II][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0040. Combination Sum II][0040. Combination Sum II]]
|
||||
:END:
|
||||
|
||||
Given a collection of candidate numbers (~candidates~) and a target number (~target~), find all unique combinations in ~candidates~ where the candidate numbers sum to ~target~.
|
||||
|
||||
Each number in ~candidates~ may only be used *once* in the combination.
|
||||
|
||||
*Note:* The solution set must not contain duplicate combinations.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: candidates = [10,1,2,7,6,1,5], target = 8
|
||||
Output:
|
||||
[
|
||||
[1,1,6],
|
||||
[1,2,5],
|
||||
[1,7],
|
||||
[2,6]
|
||||
]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: candidates = [2,5,2,1,2], target = 5
|
||||
Output:
|
||||
[
|
||||
[1,2,2],
|
||||
[5]
|
||||
]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= candidates.length <= 100~
|
||||
|
||||
- ~1 <= candidates[i] <= 50~
|
||||
|
||||
- ~1 <= target <= 30~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,57 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0046. Permutations :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0046. Permutations][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0046. Permutations][0046. Permutations]]
|
||||
:END:
|
||||
|
||||
Given an array ~nums~ of distinct integers, return all the possible permutations. You can return the answer in *any order*.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [1,2,3]
|
||||
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
|
||||
#+end_src
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [0,1]
|
||||
Output: [[0,1],[1,0]]
|
||||
#+end_src
|
||||
*Example 3:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [1]
|
||||
Output: [[1]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= nums.length <= 6~
|
||||
|
||||
- ~-10 <= nums[i] <= 10~
|
||||
|
||||
- All the integers of ~nums~ are *unique*.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def permute(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> permute(vector<int>& nums) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,53 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0051. N Queens :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0051. N Queens][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0051. N Queens][0051. N Queens]]
|
||||
:END:
|
||||
|
||||
The *n-queens* puzzle is the problem of placing ~n~ queens on an ~n x n~ chessboard such that no two queens attack each other.
|
||||
|
||||
Given an integer ~n~, return /all distinct solutions to the *n-queens puzzle*/. You may return the answer in *any order*.
|
||||
|
||||
Each solution contains a distinct board configuration of the n-queens' placement, where ~'Q'~ and ~'.'~ both indicate a queen and an empty space, respectively.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 4
|
||||
Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
|
||||
Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 1
|
||||
Output: [["Q"]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= n <= 9~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def solveNQueens(self, n: int) -> List[List[str]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<string>> solveNQueens(int n) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,51 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0052. N Queens II :hard:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0052. N Queens II][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0052. N Queens II][0052. N Queens II]]
|
||||
:END:
|
||||
|
||||
The *n-queens* puzzle is the problem of placing ~n~ queens on an ~n x n~ chessboard such that no two queens attack each other.
|
||||
|
||||
Given an integer ~n~, return /the number of distinct solutions to the *n-queens puzzle*/.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 4
|
||||
Output: 2
|
||||
Explanation: There are two distinct solutions to the 4-queens puzzle as shown.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 1
|
||||
Output: 1
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= n <= 9~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def totalNQueens(self, n: int) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
int totalNQueens(int n) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,55 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0077. Combinations :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0077. Combinations][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0077. Combinations][0077. Combinations]]
|
||||
:END:
|
||||
|
||||
Given two integers ~n~ and ~k~, return /all possible combinations of/ ~k~ /numbers chosen from the range/ ~[1, n]~.
|
||||
|
||||
You may return the answer in *any order*.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 4, k = 2
|
||||
Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
|
||||
Explanation: There are 4 choose 2 = 6 total combinations.
|
||||
Note that combinations are unordered, i.e., [1,2] and [2,1] are considered to be the same combination.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: n = 1, k = 1
|
||||
Output: [[1]]
|
||||
Explanation: There is 1 choose 1 = 1 total combination.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= n <= 20~
|
||||
|
||||
- ~1 <= k <= n~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def combine(self, n: int, k: int) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> combine(int n, int k) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,54 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0078. Subsets :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0078. Subsets][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0078. Subsets][0078. Subsets]]
|
||||
:END:
|
||||
|
||||
Given an integer array ~nums~ of *unique* elements, return /all possible/ /subsets/ /(the power set)/.
|
||||
|
||||
The solution set *must not* contain duplicate subsets. Return the solution in *any order*.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [1,2,3]
|
||||
Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [0]
|
||||
Output: [[],[0]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= nums.length <= 10~
|
||||
|
||||
- ~-10 <= nums[i] <= 10~
|
||||
|
||||
- All the numbers of ~nums~ are *unique*.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def subsets(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> subsets(vector<int>& nums) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,69 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0079. Word Search :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0079. Word Search][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0079. Word Search][0079. Word Search]]
|
||||
:END:
|
||||
|
||||
Given an ~m x n~ grid of characters ~board~ and a string ~word~, return ~true~ /if/ ~word~ /exists in the grid/.
|
||||
|
||||
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
|
||||
Output: true
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"
|
||||
Output: true
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 3:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"
|
||||
Output: false
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~m == board.length~
|
||||
|
||||
- ~n = board[i].length~
|
||||
|
||||
- ~1 <= m, n <= 6~
|
||||
|
||||
- ~1 <= word.length <= 15~
|
||||
|
||||
- ~board~ and ~word~ consists of only lowercase and uppercase English letters.
|
||||
|
||||
*Follow up:* Could you use search pruning to make your solution faster with a larger ~board~?
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def exist(self, board: List[List[str]], word: str) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
bool exist(vector<vector<char>>& board, string word) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,50 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0090. Subsets II :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0090. Subsets II][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0090. Subsets II][0090. Subsets II]]
|
||||
:END:
|
||||
|
||||
Given an integer array ~nums~ that may contain duplicates, return /all possible/ /subsets// (the power set)/.
|
||||
|
||||
The solution set *must not* contain duplicate subsets. Return the solution in *any order*.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [1,2,2]
|
||||
Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
|
||||
#+end_src
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: nums = [0]
|
||||
Output: [[],[0]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= nums.length <= 10~
|
||||
|
||||
- ~-10 <= nums[i] <= 10~
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> subsetsWithDup(vector<int>& nums) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,18 +1,48 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0131. Palindrome Partitioning :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0131. Palindrome Partitioning][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0131. Palindrome Partitioning][0131. Palindrome Partitioning]]
|
||||
:END:
|
||||
|
||||
Given a string ~s~, partition ~s~ such that every substring of the partition is a *palindrome*. Return /all possible palindrome partitioning of /~s~.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: s = "aab"
|
||||
Output: [["a","a","b"],["aa","b"]]
|
||||
#+end_src
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: s = "a"
|
||||
Output: [["a"]]
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= s.length <= 16~
|
||||
|
||||
- ~s~ contains only lowercase English letters.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def partition(self, s: str) -> List[List[str]]:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<string>> partition(string s) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0351. Android Unlock Patterns :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0351. Android Unlock Patterns][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0351. Android Unlock Patterns][0351. Android Unlock Patterns]]
|
||||
:END:
|
||||
|
||||
** TODO Approach
|
||||
|
||||
@@ -1,18 +1,62 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 1079. Letter Tile Possibilities :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*1079. Letter Tile Possibilities][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*1079. Letter Tile Possibilities][1079. Letter Tile Possibilities]]
|
||||
:END:
|
||||
|
||||
You have ~n~ ~tiles~, where each tile has one letter ~tiles[i]~ printed on it.
|
||||
|
||||
Return /the number of possible non-empty sequences of letters/ you can make using the letters printed on those ~tiles~.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: tiles = "AAB"
|
||||
Output: 8
|
||||
Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA".
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: tiles = "AAABBC"
|
||||
Output: 188
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 3:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: tiles = "V"
|
||||
Output: 1
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= tiles.length <= 7~
|
||||
|
||||
- ~tiles~ consists of uppercase English letters.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def numTilePossibilities(self, tiles: str) -> int:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
int numTilePossibilities(string tiles) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user