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
@@ -46,13 +46,13 @@ Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 9 :lc-lang python3
class Solution:
def isPalindrome(self, x: int) -> bool:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 9
class Solution {
public:
bool isPalindrome(int x) {
@@ -98,13 +98,13 @@ Note: 49 is not 1 (I) less of 50 (L) because the conversion is based on decimal
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 12 :lc-lang python3
class Solution:
def intToRoman(self, num: int) -> str:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 12
class Solution {
public:
string intToRoman(int num) {
@@ -36,13 +36,13 @@ Output: "56088"
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 43 :lc-lang python3
class Solution:
def multiply(self, num1: str, num2: str) -> str:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 43
class Solution {
public:
string multiply(string num1, string num2) {
@@ -38,7 +38,7 @@ Output: [[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 48 :lc-lang python3
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
@@ -47,7 +47,7 @@ class Solution:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 48
class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
@@ -8,11 +8,11 @@
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 50 :lc-lang python3
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 50
#+end_src
@@ -38,13 +38,13 @@ Output: [1,2,3,4,8,12,11,10,9,5,6,7]
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 54 :lc-lang python3
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 54
class Solution {
public:
vector<int> spiralOrder(vector<vector<int>>& matrix) {
@@ -56,13 +56,13 @@ Thus, the result should be [1,0].
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 66 :lc-lang python3
class Solution:
def plusOne(self, digits: List[int]) -> List[int]:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 66
class Solution {
public:
vector<int> plusOne(vector<int>& digits) {
@@ -48,7 +48,7 @@ Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 73 :lc-lang python3
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
@@ -57,7 +57,7 @@ class Solution:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 73
class Solution {
public:
void setZeroes(vector<vector<int>>& matrix) {
@@ -47,13 +47,13 @@ Output: false
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 202 :lc-lang python3
class Solution:
def isHappy(self, n: int) -> bool:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 202
class Solution {
public:
bool isHappy(int n) {
@@ -8,11 +8,11 @@
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 296 :lc-lang python3
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 296
#+end_src
@@ -48,13 +48,13 @@ Output: 0
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 840 :lc-lang python3
class Solution:
def numMagicSquaresInside(self, grid: List[List[int]]) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 840
class Solution {
public:
int numMagicSquaresInside(vector<vector<int>>& grid) {
@@ -45,13 +45,13 @@ Output: false
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 1780 :lc-lang python3
class Solution:
def checkPowersOfThree(self, n: int) -> bool:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 1780
class Solution {
public:
bool checkPowersOfThree(int n) {
@@ -57,7 +57,7 @@ detectSquares.count([11, 10]); // return 2. You can choose:
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2013 :lc-lang python3
class DetectSquares:
def __init__(self):
@@ -77,7 +77,7 @@ class DetectSquares:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2013
class DetectSquares {
public:
DetectSquares() {
@@ -48,7 +48,7 @@ The last space in the matrix is set to -1.
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2326 :lc-lang python3
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
@@ -59,7 +59,7 @@ class Solution:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2326
/**
* Definition for singly-linked list.
* struct ListNode {
@@ -49,13 +49,13 @@ Hence, the punishment number of 37 is 1 + 81 + 100 + 1296 = 1478
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 2698 :lc-lang python3
class Solution:
def punishmentNumber(self, n: int) -> int:
#+end_src
** TODO C++
#+begin_src cpp
#+begin_src cpp :lc-problem 2698
class Solution {
public:
int punishmentNumber(int n) {