This commit is contained in:
2026-05-25 12:29:20 +05:00
parent 9d30fc897c
commit ec7f45e03a
4 changed files with 102 additions and 0 deletions

9
solutions/lc1.py Normal file
View File

@@ -0,0 +1,9 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = {}
for i, x in enumerate(nums):
need = target - x
if need in seen:
return [seen[need], i]
seen[x] = i

16
solutions/lc1365.py Normal file
View File

@@ -0,0 +1,16 @@
class Solution:
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
count = {}
for num in nums:
count[num] = count.get(num, 0) + 1
sorted_nums = sorted(count)
less_count = {}
current = 0
for num in sorted_nums:
less_count[num] = current
current += count[num]
return [less_count[num] for num in nums]

9
solutions/lc2540.py Normal file
View File

@@ -0,0 +1,9 @@
class Solution:
def getCommon(self, nums1: List[int], nums2: List[int]) -> int:
s1 = set(nums1)
for num in nums2:
if num in s1:
return num
else:
return -1