Maximize Score After N Operations of Leetcode || DP with Bitmasking || C++/Java/Python || DP

preview_player
Показать описание
In this video, I'll talk about how to solve the problem - 1799. Maximize Score After N Operations of Leetcode

Maximize Score After N Operations of Leetcode || DP + Bitmasking || C++/Java/Python || DP

Let's Connect:

🛍️ Products I use in Videos: (✨ Marked for Mostly requested Products)

Resources you can try:

🎥Channel Playlists

About Channel:
We teach about how you can grow in life & educate about programming in Fun & Intuitional way.

About Me:
I am Aryan Mittal - a Software Engineer, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)

✨ Timelines✨
0:00 - Bakwas
0:56 - Problem Explanation
6:09 - Intuition
12:34 - How to Code these kinds of Problems
19:31 - All about Masking
25:51 - Recursion Memoization
32:54 - Complexity Analysis
34:51 - Optimizing the code more

✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
Рекомендации по теме
Комментарии
Автор


It's a very good problem, highly highly recommended to watch 🤩

ARYANMITTAL
Автор

bhai thnx yar..best solution ..really helped me a lot..keep up

mayankgarg
Автор

Your videos are a gold mine. You're not far from gaining a million subscribers with this content

HimanshuDagar-krct
Автор

Bhai no other way to describe orgasmic bhai lagra tha kuch samaj nahi aaega but hawa lagg gayi. Multiple baar dekhni padegi. Dhanyavaad bahut bahut anycase.

anonnona
Автор

thank you for putting so much efforts for us

sushmajha
Автор

aryan thanks for neat and clear explanation from basics to advance

devanshpurwar
Автор

Thanks for the videos!!!!.If u could provide a dry of any one example it would be even better 😄

shaunak
Автор

Great work brother keep doing it thanks :)

shivasai
Автор

Nice . Top level explaination to top level question!!!!

nimeshsingh
Автор

Bhai Aisa hi dp on bitmasking ka ek accha question. Leetcode 1994: The number of good subsets hai . Usko bhi aise explain karke 1 vedio bna do pls..

kunwerbahadursingh
Автор

Loved the explanation man!!! Much appreciated, the work u put in is v much visible

mohitgodara
Автор

I used this base condition instead

if(mask == (1<<n) - 1) return 0;

AbhishekYadav-rmhw
Автор

One Doubt : if in 1st operation we select (i, j) and set the mask and in second operation select (k, l) then our mask would be (i, j, k, l) are set but if we change the pair orientation then also mask is same [(i, k), (j, l)] then how memoization part is working here? @Aryan Mitttal

Learner
Автор

in brute force approach shouldn't the total number of pairs to be selected will be Nc2 rather than n square

zoddd
Автор

i did not understand how you came up for 1D dp? as "operations" paramater was also changing, so i thought dp state would be dp[operation][mask]? please help why 2D not required @Aryan Mittal

dhanashreegodase
Автор

can you make a video about your coding journey?

raginibhayana
Автор

Why this method doesnt work ?

class Solution:
def maxScore(self, nums: List[int]) -> int:
heap=[]
numDict=Counter(nums)
n2=len(nums)
n=n2//2
for i in range(n2):
for j in range(i+1, n2):
heapq.heappush(heap, (-math.gcd(nums[i], nums[j]), nums[i], nums[j]))
res=0
while(heap and n):
gcd, num1, num2=heapq.heappop(heap)
if not numDict[num1] or not numDict[num2]:
continue
numDict[num1]-=1
numDict[num2]-=1
res+=-gcd*n
n-=1
return res

PRANAVMAPPOLI