0% found this document useful (0 votes)
120 views

neetcode_150_plan

Uploaded by

Punith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

neetcode_150_plan

Uploaded by

Punith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Day Topic Pattern/TrickProblem

Brute-Force Approach
OptimalBrute-Force
Approach Pseudo
OptimalCode
Pseudo Code
1 Arrays & HHashMap fo Two Sum Use nestedUse a Hashfor i in ran map = {} for i, num in enumerate(nums): complem
1 Arrays & HUse HashSeContains DCompare ea Use HashSefor i in ran seen = set() for num in nums: if num in seen: retur
2 Two PointeLeft and RiValid Pali Reverse theUse two poreturn s ==left, right = 0, len(s) - 1 while left < right: if s[left] !=
2 Two PointeSort + TwoTwo Sum IIUse nestedUse two poifor i in ran left, right = 0, len(nums) - 1 while left < right: if num
3 Sliding Wi Expand an Best Time tCheck profiTrack min pmax_profitmin_price, max_profit = float('inf'), 0 for price in pr
n enumerate(nums): complement = target - num if complement in map: return [map[complement], i] map[num] = i
in nums: if num in seen: return True seen.add(num) return False
1 while left < right: if s[left] != s[right]: return False left += 1; right -= 1 return True
ms) - 1 while left < right: if nums[left] + nums[right] == target: return [left+1, right+1] elif nums[left] + nums[right] < target: left += 1 else: ri
fit = float('inf'), 0 for price in prices: min_price = min(min_price, price) max_profit = max(max_profit, price - min_price) return max_profit
right] < target: left += 1 else: right -= 1
min_price) return max_profit

You might also like