Skip to content

Commit f88806e

Browse files
committed
Improved python
1 parent 0a5c1c3 commit f88806e

File tree

64 files changed

+239
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+239
-2
lines changed

src/main/python/g0001_0100/s0015_3sum/Solution0015.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# #Top_Interview_150_Two_Pointers #Big_O_Time_O(n*log(n))_Space_O(n^2)
44
# #2025_07_22_Time_581_ms_(56.92%)_Space_20.72_MB_(36.56%)
55

6+
from typing import List
7+
68
class Solution:
79
def threeSum(self, nums: List[int]) -> List[List[int]]:
810
nums.sort()

src/main/python/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution0017.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# #Udemy_Backtracking/Recursion #Top_Interview_150_Backtracking #Big_O_Time_O(4^n)_Space_O(n)
44
# #2025_07_22_Time_0_ms_(100.00%)_Space_17.68_MB_(92.03%)
55

6+
from typing import List
7+
68
class Solution:
79
def letterCombinations(self, digits: str) -> List[str]:
810
if not digits:

src/main/python/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution0019.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# #Algorithm_I_Day_5_Two_Pointers #Level_2_Day_3_Linked_List #Top_Interview_150_Linked_List
33
# #Big_O_Time_O(L)_Space_O(L) #2025_07_22_Time_0_ms_(100.00%)_Space_17.70_MB_(84.76%)
44

5+
from typing import Optional
6+
7+
class ListNode:
8+
def __init__(self, val=0, next=None):
9+
self.val = val
10+
self.next = next
11+
512
# Definition for singly-linked list.
613
# class ListNode:
714
# def __init__(self, val=0, next=None):

src/main/python/g0001_0100/s0021_merge_two_sorted_lists/Solution0021.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# #Level_1_Day_3_Linked_List #Udemy_Linked_List #Top_Interview_150_Linked_List
44
# #Big_O_Time_O(m+n)_Space_O(m+n) #2025_07_22_Time_0_ms_(100.00%)_Space_17.70_MB_(61.28%)
55

6+
from typing import Optional
7+
8+
class ListNode:
9+
def __init__(self, val=0, next=None):
10+
self.val = val
11+
self.next = next
12+
613
# Definition for singly-linked list.
714
# class ListNode:
815
# def __init__(self, val=0, next=None):

src/main/python/g0001_0100/s0022_generate_parentheses/Solution0022.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# #Top_Interview_150_Backtracking #Big_O_Time_O(2^n)_Space_O(n)
44
# #2025_07_22_Time_0_ms_(100.00%)_Space_18.17_MB_(25.52%)
55

6+
from typing import List
7+
68
class Solution:
79
def generateParenthesis(self, n: int) -> List[str]:
810
ans = []

src/main/python/g0001_0100/s0023_merge_k_sorted_lists/Solution0023.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# #Divide_and_Conquer #Merge_Sort #Top_Interview_150_Divide_and_Conquer
33
# #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) #2025_07_22_Time_5_ms_(93.52%)_Space_20.28_MB_(55.14%)
44

5+
from typing import List, Optional
6+
7+
class ListNode:
8+
def __init__(self, val=0, next=None):
9+
self.val = val
10+
self.next = next
11+
512
# Definition for singly-linked list.
613
# class ListNode:
714
# def __init__(self, val=0, next=None):

src/main/python/g0001_0100/s0024_swap_nodes_in_pairs/Solution0024.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# #Udemy_Linked_List #Big_O_Time_O(n)_Space_O(1)
33
# #2025_07_22_Time_0_ms_(100.00%)_Space_17.66_MB_(83.09%)
44

5+
from typing import Optional
6+
7+
class ListNode:
8+
def __init__(self, val=0, next=None):
9+
self.val = val
10+
self.next = next
11+
512
# Definition for singly-linked list.
613
# class ListNode:
714
# def __init__(self, val=0, next=None):

src/main/python/g0001_0100/s0025_reverse_nodes_in_k_group/Solution0025.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# #Udemy_Linked_List #Top_Interview_150_Linked_List #Big_O_Time_O(n)_Space_O(k)
33
# #2025_07_22_Time_0_ms_(100.00%)_Space_18.73_MB_(19.01%)
44

5+
from typing import Optional
6+
7+
class ListNode:
8+
def __init__(self, val=0, next=None):
9+
self.val = val
10+
self.next = next
11+
512
# Definition for singly-linked list.
613
# class ListNode:
714
# def __init__(self, val=0, next=None):

src/main/python/g0001_0100/s0031_next_permutation/Solution0031.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# #Medium #Top_100_Liked_Questions #Array #Two_Pointers #Big_O_Time_O(n)_Space_O(1)
22
# #2025_07_22_Time_0_ms_(100.00%)_Space_17.71_MB_(56.73%)
33

4+
from typing import List
5+
46
class Solution:
57
def nextPermutation(self, nums: List[int]) -> None:
68
"""

src/main/python/g0001_0100/s0033_search_in_rotated_sorted_array/Solution0033.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# #Udemy_Binary_Search #Top_Interview_150_Binary_Search #Big_O_Time_O(log_n)_Space_O(1)
44
# #2025_07_22_Time_0_ms_(100.00%)_Space_18.28_MB_(22.25%)
55

6+
from typing import List
7+
68
class Solution:
79
def search(self, nums: List[int], target: int) -> int:
810
lo, hi = 0, len(nums) - 1

0 commit comments

Comments
 (0)