1518. Water Bottles | Maths | leetcode daily challenge | DSA | Hindi
HTML-код
- Опубликовано: 22 авг 2024
- Problem Name:
1518. Water Bottles
Problem Statement:
There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.
The operation of drinking a full water bottle turns it into an empty bottle.
Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.
Problem Link:
leetcode.com/p...
Graph Playlist:
• Graph Data Structure S...
Java Plus DSA Placement Course Playlist:
• Java and DSA Course Pl...
Java Plus DSA Sheet:
docs.google.co...
Notes:
github.com/Tiw...
Telegram Link:
shashwattiwari...
Ultimate Recursion Series Playlist:
• Recursion and Backtrac...
Instagram Handle: (@shashwat_tiwari_st)
shashwattiwari...
Samsung Interview Experience:
• I cracked Samsung | SR...
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding #problemsolving
like target for this video is 80. Please do like if you understood the solution 😄
Hi sir! 👋
I am a beginner in coding. I have just started following your DSA course and found it very useful🥰. Most of these topics have pre-written notes.
But I am confused whether I should make notes of problems.
I have completed almost 20 videos. Now I am on binary search. But for now, I paused watching more videos. Rather than that I am now focusing on Leet code problem solving of Bit Manipulation as u said that u guys should start solving problems on Leet code.
But the problem is that There are thousands of problems and as a beginner I feel confused which problem to take, and which problem I should mention in notes and what to write on notes whether the code or explanation or something else.
Moreover, I think I can only solve problem in brute force way, some problems have many things in their topics section like dynamic programming, backtracking, etc... and I don't even know their meaning🥲.
And I also had to ask that for example I have watched your Bit manipulation videos, Whether I should stop learning any other topic till I clear Bit manipulation. Like how I should manage videos with problem solving. like how many problems I have to solve on bit manipulation before moving onto the next topic. Whether I have to solve easy, medium and hard, all problems before moving onto the next topic...? or I can solve only easy and medium problems for now and move on to the next topic or I have to solve hard problems with easy and medium problems...?
kindly explain me how I can manage all these things, I shall be very thankful to you for your guidance. Or u can also make a video on it to help other beginners like me as it can also be a problem of many others 😊
plz reply..!
@@techgamermadno910 Hey, see when I said that you should solve problems, then I meant that you should do "leetcode daily challege", GFG POTD etc of the topics you have studied.
Also, attend weekly contests.
If any question comes (in contest or in daily challenge problems) that you haven't studied then you can skip it.
Also about notes, you can check this one.
ruclips.net/video/QL-XAG_8Y2k/видео.htmlsi=YwgGI7-iEdYS5K5q
Please don't stop your learning of DSA topics just because you want to solve leetcode problems.
Keep them parallel!
Thanks 😊 it also helped me . @@shashwat_tiwari_st
@@techgamermadno910Thanks to ask 😊
@@shashwat_tiwari_st Thanks❤️
Thanks 😊
Brother You deserve more
i solved it suing recursion though :(
class Solution {
public:
int recurssion(int numBottles, int numExchange, int empty, int& anss)
{
//base case
if(numBottles == 0 && empty < numExchange) return anss;
//now we will solve 1 case, recurssion
if(numBottles > 0)
{
anss = anss + numBottles;
empty = empty + numBottles;
numBottles = 0;
}
//refilling
if(empty >= numExchange)
{
numBottles = empty / numExchange;
empty = empty % numExchange;
}
recurssion(numBottles, numExchange, empty, anss);
return anss;
}
int numWaterBottles(int numBottles, int numExchange) {
//recurssion
int anss = 0;
int empty = 0;
int ans = recurssion(numBottles, numExchange, empty, anss);
return ans;
}
};
Love from Russia❤
😊
Hello sir thank you for making these videos
wait krte hain daily leetcode problem ke liye approach aagya tha mind me
Nice explain sir ❤
i did it today with 100 % beats🙂🙂
Easy peasy lemon squeezy
Done by itself bhaiya
Just here for attendance 😅
attendance completeddd😌
Aapka channel dekhna majboori me shuru kiye the, ab maza aa rha hai💀💀
Are are 😂
numBottles + (numBottles - 1) // (numExchange - 1) one line soln
Can you please tell me aap konsa pen tablet use krte ho
bhai aaj constant time solution nahi samjhaya