4Sum - Leetcode 18 - Two Pointers (Python)

  Рет қаралды 3,575

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер: 9
@GregHogg
@GregHogg 4 ай бұрын
Master Data Structures & Algorithms for FREE at AlgoMap.io/
@JoeTan-nq4fq
@JoeTan-nq4fq 2 ай бұрын
If it is a k sum problem, does it mean we need to resort to recursive solution (until we end up with 2 sum problem)?
@mitranshuraj2811
@mitranshuraj2811 5 ай бұрын
Feels kinda bad to understand these topics😂
@gourav6968
@gourav6968 4 ай бұрын
oi, why is it?
@mitranshuraj2811
@mitranshuraj2811 4 ай бұрын
​@@gourav69682sum, 3sum, 4sum, dp...shall I go on?
@donkeykong5616
@donkeykong5616 11 күн бұрын
Better than neetcode lol
@Fen-i3n
@Fen-i3n 3 ай бұрын
sorry but I dont know how to do 3 sum😮‍💨
@xingyuxiang1637
@xingyuxiang1637 19 күн бұрын
Build a graph and then traverse it. Hashing on nodes, integers, or IDs. class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: nums.sort() n = len(nums) seen = set() ans = set() for i in range(n): for j in range(i + 1, n): lastNumber = - nums[i] - nums[j] if lastNumber in seen: ans.add((nums[i], nums[j], lastNumber)) seen.add(nums[i]) return ans class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: nums.sort() n = len(nums) seen = set() ans = set() for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): lastNumber = target - nums[i] - nums[j] - nums[k] if lastNumber in seen: ans.add((nums[i], nums[j], nums[k], lastNumber)) seen.add(nums[i]) return ans
3Sum Closest - Leetcode 16 - Two Pointers (Python)
8:54
Greg Hogg
Рет қаралды 4,5 М.
3Sum (Updated Solution) - Leetcode 15 - Two Pointers (Python)
11:11
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН
Remove Element - Leetcode 27 - 2 Pointers (Python)
4:56
Greg Hogg
Рет қаралды 4,2 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 770 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 1,1 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 676 М.
Number of Islands - Leetcode 200 - Graphs (Python)
11:01
Greg Hogg
Рет қаралды 12 М.
How He Got $600,000 Data Engineer Job
19:08
Sundas Khalid
Рет қаралды 188 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 593 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 242 М.