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​

Комментарии • 24

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  Месяц назад +8

    like target for this video is 80. Please do like if you understood the solution 😄

    • @techgamermadno910
      @techgamermadno910 Месяц назад +1

      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..!

    • @shashwat_tiwari_st
      @shashwat_tiwari_st  Месяц назад +3

      @@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!

    • @RohitKumar-dz8dh
      @RohitKumar-dz8dh Месяц назад +1

      Thanks 😊 it also helped me . ​@@shashwat_tiwari_st

    • @RohitKumar-dz8dh
      @RohitKumar-dz8dh Месяц назад +1

      ​@@techgamermadno910Thanks to ask 😊

    • @techgamermadno910
      @techgamermadno910 Месяц назад

      @@shashwat_tiwari_st Thanks❤️

  • @RohitKumar-dz8dh
    @RohitKumar-dz8dh Месяц назад +1

    Thanks 😊

  • @arnab027
    @arnab027 Месяц назад

    Brother You deserve more

  • @saiei
    @saiei Месяц назад +1

    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;
    }
    };

  • @GirjeshSharma-zv3xo
    @GirjeshSharma-zv3xo Месяц назад

    Love from Russia❤

  • @user-rz7iw4pl4i
    @user-rz7iw4pl4i Месяц назад

    😊

  • @engineer9503
    @engineer9503 Месяц назад

    Hello sir thank you for making these videos

  • @Nishant89-i2z
    @Nishant89-i2z Месяц назад

    wait krte hain daily leetcode problem ke liye approach aagya tha mind me

  • @mr.nishantawasthi4402
    @mr.nishantawasthi4402 Месяц назад

    Nice explain sir ❤

  • @PrakashRai-ff3pr
    @PrakashRai-ff3pr Месяц назад

    i did it today with 100 % beats🙂🙂

  • @ShivamMaurya-ee4zp
    @ShivamMaurya-ee4zp Месяц назад

    Easy peasy lemon squeezy
    Done by itself bhaiya
    Just here for attendance 😅

  • @adarshjain3058
    @adarshjain3058 Месяц назад

    attendance completeddd😌

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd Месяц назад

    Aapka channel dekhna majboori me shuru kiye the, ab maza aa rha hai💀💀

  • @Death-metal99
    @Death-metal99 Месяц назад

    numBottles + (numBottles - 1) // (numExchange - 1) one line soln

  • @engineer9503
    @engineer9503 Месяц назад

    Can you please tell me aap konsa pen tablet use krte ho

  • @PiyushYadav-pl9jm
    @PiyushYadav-pl9jm Месяц назад

    bhai aaj constant time solution nahi samjhaya