This commit is contained in:
2026-06-05 22:32:49 +08:00
parent 14d05011d5
commit c67841fe07
202 changed files with 498 additions and 403 deletions
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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
@@ -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) {