Skip to content

Commit c3a86df

Browse files
committed
Improved tasks 236-347
1 parent 58bf7d9 commit c3a86df

11 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/main/python/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/
4646
## Solution
4747

4848
```python
49+
class TreeNode:
50+
def __init__(self, val=0, left=None, right=None):
51+
self.val = val
52+
self.left = left
53+
self.right = right
54+
4955
# Definition for a binary tree node.
5056
# class TreeNode:
5157
# def __init__(self, x):

src/main/python/g0201_0300/s0238_product_of_array_except_self/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ You must write an algorithm that runs in `O(n)` time and without using the divis
3434
## Solution
3535

3636
```python
37+
from typing import List
38+
3739
class Solution:
3840
def productExceptSelf(self, nums: List[int]) -> List[int]:
3941
product = 1

src/main/python/g0201_0300/s0239_sliding_window_maximum/readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Return _the max sliding window_.
5959
## Solution
6060

6161
```python
62+
from typing import List
63+
from collections import deque
64+
6265
class Solution:
6366
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
6467
q = deque()

src/main/python/g0201_0300/s0240_search_a_2d_matrix_ii/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Write an efficient algorithm that searches for a `target` value in an `m x n` in
3939
## Solution
4040

4141
```python
42+
from typing import List
43+
4244
class Solution:
4345
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
4446
if not matrix or not matrix[0]:

src/main/python/g0201_0300/s0283_move_zeroes/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Given an integer array `nums`, move all `0`'s to the end of it while maintaining
3131
## Solution
3232

3333
```python
34+
from typing import List
35+
3436
class Solution:
3537
def moveZeroes(self, nums: List[int]) -> None:
3638
"""

src/main/python/g0201_0300/s0287_find_the_duplicate_number/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ You must solve the problem **without** modifying the array `nums` and uses only
5050
## Solution
5151

5252
```python
53+
from typing import List
54+
5355
class Solution:
5456
def findDuplicate(self, nums: List[int]) -> int:
5557
arr = [0] * (len(nums) + 1)

src/main/python/g0201_0300/s0295_find_median_from_data_stream/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Implement the MedianFinder class:
4848
## Solution
4949

5050
```python
51+
from typing import List
52+
5153
import heapq
5254

5355
class MedianFinder:

src/main/python/g0201_0300/s0300_longest_increasing_subsequence/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ A **subsequence** is a sequence that can be derived from an array by deleting so
3939
## Solution
4040

4141
```python
42+
from typing import List
4243
import bisect
4344

4445
class Solution:

src/main/python/g0301_0400/s0322_coin_change/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ You may assume that you have an infinite number of each kind of coin.
4040
## Solution
4141

4242
```python
43+
from typing import List
44+
4345
class Solution:
4446
def coinChange(self, coins: List[int], amount: int) -> int:
4547
dp = [0] * (amount + 1)

src/main/python/g0301_0400/s0338_counting_bits/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for
4646
## Solution
4747

4848
```python
49+
from typing import List
50+
4951
class Solution:
5052
def countBits(self, num: int) -> List[int]:
5153
result = [0] * (num + 1)

0 commit comments

Comments
 (0)