Тёмный

Minimum Operations to Reduce X to Zero | O(N) Optimal | Leetcode #1658 

Подписаться
Просмотров 19 тыс.
% 395

This video explains a very important programming interview problem which is to find the minimum number of operations to reduce a given number X to 0.I have already explained the dynamic programming solution for this problem in my previous video.Here, I have explained the optimal approach using hashmap.I have first solved the problem statement using proper examples and then i have shown the intuition for solving this problem. I have used easy examples and I have shown the algorithm using dry run.At the end, I have also shown the code walkthrough.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
========================================================================
Join this channel to get access to perks:
ru-vid.com/show-UCnxhETjJtTPs37hOZ7vQ88gjoin
INSTAGRAM : surya.pratap.k
SUPPORT OUR WORK: www.patreon.com/techdose
LinkedIn: www.linkedin.com/in/surya-pratap-kahar-47bb01168
WEBSITE: techdose.co.in/
TELEGRAM Channel LINK: t.me/codewithTECHDOSE
TELEGRAM Group LINK: t.me/joinchat/SRVOIxWR4sRIVv5eEGI4aQ
=======================================================================
CODE LINK: gist.github.com/SuryaPratapK/5dfc2c5c68a21a12d3593f085c5212ce
USEFUL LINKS:-
Minimum Operations to Reduce X to Zero DP: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-HddgLcq9Efs.html
Subarray sum equals K: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-HbbYPQc-Oo4.html
Perfect subarray: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Lyay4WJwXyI.html
#subarray #minimum #Xto0

Опубликовано:

 

19 ноя 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@peterbarter4647
@peterbarter4647 3 года назад
Minimum operation sir.... You wrote maximum 😅🤣.... Thank you so much, I was waiting for this from yesterday
@techdose4u
@techdose4u 3 года назад
Got it 😅 pardon me 😅
@pryansh_
@pryansh_ Год назад
It was really helpful, thanks for the content.
@nayanjain5761
@nayanjain5761 3 года назад
Like me some us already be knowing sub-array sum problem solutions but converting this one into it really amazed me, I would have never thought this way. Thanks :)
@puneethj9920
@puneethj9920 3 года назад
This type of intuition is too good! Loved it ! Thank You sir 🙌
@techdose4u
@techdose4u 3 года назад
Welcome :)
@punyagupta8086
@punyagupta8086 3 года назад
Amazing explanation of a very tricky problem!!
@ameynaik2743
@ameynaik2743 3 года назад
In general is there a signature of such kinds of problems? I would have never thought of this solution!
@techdose4u
@techdose4u 3 года назад
I think this is just logic based. Need some practice to solve it without even giving it a second thought :)
@vamsimudaliar8643
@vamsimudaliar8643 3 года назад
Wow, i love this intuition ! Thanks sir u explained it really well
@techdose4u
@techdose4u 3 года назад
Welcome :)
@srinivasm3045
@srinivasm3045 3 года назад
Sir we can use sum 0 at index -1 that way we don’t have to check whether val-sum=0
@techdose4u
@techdose4u 3 года назад
If it works then no issues :)
@BULLSHXTYT
@BULLSHXTYT 2 года назад
18:45 The map has wrong index right? It confused me for half an hour.
@girrajjangid4681
@girrajjangid4681 Год назад
why you are putting 4 as value of 6 in HashMap?
@shree1365
@shree1365 3 года назад
Sir I got placed 😍 thanku sir for shearing knowledge
@techdose4u
@techdose4u 3 года назад
Nice bro :) Congratulations 🎉 Keep learning and improving :D
@vaibhavsaxena1260
@vaibhavsaxena1260 2 года назад
Thank you! You added one more subscription!!
@Ashwinraj-dd1dn
@Ashwinraj-dd1dn 3 года назад
Along with c++ code, please add java code to all your videos🙏🙏
@techdose4u
@techdose4u 3 года назад
I will do that soon. I am working on java now.
@Ashwinraj-dd1dn
@Ashwinraj-dd1dn 3 года назад
@@techdose4u thank you sir🙏😊
@coursesforyou7608
@coursesforyou7608 Год назад
03:21 Minimum number of operations to reduce x to zero using boundary elements 06:42 To convert a given number x to zero, find the longest subarray with a sum equals to the difference between the sum of all elements and x. 13:24 Efficiently finding subarrays with a given sum using prefix sums and maps 16:45 Efficiently find if there is a subarray ending at an index with a sum value equals to a given value. 20:06 The longest subarray sum equals to zero is three. 23:27 Convert x to zero by finding subarray sum equals k 26:48 Find sub arrays with given sum
@RajputAnkit11
@RajputAnkit11 2 года назад
excellent explaination
@jugaducoder6517
@jugaducoder6517 Год назад
what if in array there is zero then keys will be not unique
@DarianBenam
@DarianBenam 2 года назад
Great explanation!
@amitavamozumder73
@amitavamozumder73 3 года назад
There's a line missing, you're not adding new values to the map. can u please check
@RajputAnkit11
@RajputAnkit11 2 года назад
no bro they are getting added within the same for loop for calculatating sum
@rramya9351
@rramya9351 3 года назад
Sir please add java code to all your problems. My humble request sir🙏🙏
@techdose4u
@techdose4u 3 года назад
I will add them soon. Don't worry :)
@rramya9351
@rramya9351 3 года назад
Thank you Sir 😇😇
@Mandeepsingh-jo5cf
@Mandeepsingh-jo5cf 3 года назад
Thank you very much.
@techdose4u
@techdose4u 3 года назад
Welcome :)
@sdeBack1
@sdeBack1 3 года назад
nice video sir
@techdose4u
@techdose4u 3 года назад
Thanks
@hymnish_you
@hymnish_you 3 года назад
Thankyou :D
@techdose4u
@techdose4u 3 года назад
Welcome :)
@ayushanand1032
@ayushanand1032 2 года назад
Bro! your words creates a hell lot of confusions and irritations 😫😫