Form Number Divisible by 3 | Sliding Window Challenge | C++ Placement Course | Lecture 30.3

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • Complete C++ Placement Course (Data Structures+Algorithm) : • C++ Full Course | C++...
    Telegram: t.me/apnikaksh...
    Instagram: / dhattarwalaman
    Notes of this Lecture:

ความคิดเห็น • 45

  • @anshulsachdeva9981
    @anshulsachdeva9981 2 ปีที่แล้ว +6

    In this que, we were supposed to calculate sum of digits and not individual sums. The code ran correctly because in the sum of 12,56,84 is divisible by 3. Another function may be used for calculation of digits to correct it.

    • @ritwikdutta6914
      @ritwikdutta6914 2 ปีที่แล้ว +2

      Actually if sum is divisible by 3 then the the number written sequentially is also divisible by 3 . It's fact.
      I was also confused at start

  • @kashishjain4634
    @kashishjain4634 2 ปีที่แล้ว +3

    The condition used here is true. This can be proved by:
    Lets say 3 numbers sum is divisible by three ie (a+b+c)/3=q
    Now we want to check divisibility for concatenated number formed by a,b,c ie 100a+10b+c
    So, (100a+10b+c)/3 = (99a+9b + a+b+c)/3= 33a+3b+q
    Hence concatenated number 100a+10b+c is also divisible by 3, if a+b+c is divisible by 3

  • @piyushverma8207
    @piyushverma8207 3 ปีที่แล้ว +18

    But we did not use the fact!!. We did not add the digits of individual elements, rather we just added the numbers and nothing else. Can someone tell me what I am missing?

    • @tommylommy1333
      @tommylommy1333 3 ปีที่แล้ว +6

      There is also another fact of divisible to 3:
      If you having n numbers let's suppose n1, n2, n3......
      And if you want to make a number with all n numbers divisible by three so for that condition sum all numbers should be divisible by three

    • @sanketrajgiri3239
      @sanketrajgiri3239 3 ปีที่แล้ว +1

      @@tommylommy1333 What will be the complexity if we use the traditional adding all digits approach ?

    • @tommylommy1333
      @tommylommy1333 3 ปีที่แล้ว +1

      @@sanketrajgiri3239 but in this video method it was O(1) time complexity to add only array elements

    • @tommylommy1333
      @tommylommy1333 3 ปีที่แล้ว +1

      @@sanketrajgiri3239 i hope i cleared your doubt

  • @harshrathi8955
    @harshrathi8955 2 ปีที่แล้ว +4

    Fact was not used right…instead of individual digits we just added numbers in array?

  • @ashishrao5323
    @ashishrao5323 3 ปีที่แล้ว +3

    Chanell Monitized. 👍👍.

  • @vissamsettyroja7914
    @vissamsettyroja7914 3 ปีที่แล้ว +11

    Can u make a video/podcast on importance of doing MS degree in foreign countries

    • @aloksharma9706
      @aloksharma9706 3 ปีที่แล้ว

      th-cam.com/video/6siaSZNg7L8/w-d-xo.html

  • @GAURAVPASWAN-g1d
    @GAURAVPASWAN-g1d ปีที่แล้ว +1

    kindly provide notes of each lecture

  • @0xsh1v4m9
    @0xsh1v4m9 3 ปีที่แล้ว +5

    Please upload videos fast. I have already completed all 85 videos of this playlist.

    • @aloksharma9706
      @aloksharma9706 3 ปีที่แล้ว

      th-cam.com/video/6siaSZNg7L8/w-d-xo.html

    • @rutvikrana512
      @rutvikrana512 3 ปีที่แล้ว +1

      Then go to GFG or HackerEarth and solve problems, there are many posts on GFG also which are helpful. There are many things yet remained in this series, Hash, Heap, Graph, DP etc. don’t just rely on videos 😊

    • @0xsh1v4m9
      @0xsh1v4m9 3 ปีที่แล้ว +2

      @@rutvikrana512 already done that bro and also completed all 129 videos. Btw thanks for help

    • @rutvikrana512
      @rutvikrana512 3 ปีที่แล้ว +1

      @@0xsh1v4m9 ...Wow I now noticed '3 week ago' 😂

    • @mdekramuddin8534
      @mdekramuddin8534 2 ปีที่แล้ว +1

      Hello..I want to know that does this playlist contains complete c++ and DSA ?

  • @k.murari
    @k.murari 9 หลายเดือนก่อน

    Use keypad for better understanding. And code writing approach is not so good.

  • @sankalpsharma4890
    @sankalpsharma4890 3 ปีที่แล้ว

    Great work 👍

  • @mohakgidwani1505
    @mohakgidwani1505 3 ปีที่แล้ว +1

    Amazing Lecture as always

  • @hustlewithVaibhav
    @hustlewithVaibhav 3 ปีที่แล้ว

    Thank you 🙏🙏

  • @praveenanand5689
    @praveenanand5689 2 ปีที่แล้ว

    sum= sum+arr[j]-arr[j-k];
    yeh arr[j-k] ->yeh toh hamesa arr[0] element ko point karega
    phir next element kaise subtract honge

    • @akashchoudhary6876
      @akashchoudhary6876 2 ปีที่แล้ว

      j will increament by each loop and so will j-k

  • @dhruvsakariya3129
    @dhruvsakariya3129 ปีที่แล้ว +1

    Boolean solution
    bool isPossible(vector &nums, int k)
    {
    int len = nums.size();
    int windowSum = 0;
    for (int i = 0; i < k; i++)
    {
    windowSum += nums[i];
    }
    for (int j = k; j < len; j++)
    {
    if (windowSum % 3 == 0)
    {
    return true;
    };
    windowSum = windowSum + nums[j] - nums[j - k];
    }
    return windowSum % 3 == 0 ? true : false;
    };

  • @iamnaveenshankar
    @iamnaveenshankar 3 ปีที่แล้ว

    Is this 130 video playlist the end of placement series??

  • @KeshavSharma-ng4yr
    @KeshavSharma-ng4yr 3 ปีที่แล้ว

    Java lecture upload krna start kr dijiye !!

    • @aloksharma9706
      @aloksharma9706 3 ปีที่แล้ว

      th-cam.com/video/6siaSZNg7L8/w-d-xo.html

  • @techflying8660
    @techflying8660 3 ปีที่แล้ว +5

    Bhaiya aaj mera brithday hai 22 march

  • @Npanywayme
    @Npanywayme 3 ปีที่แล้ว

    FOR BETTER EXPAINATION VISIT ::: th-cam.com/play/PL_z_8CaSLPWeM8BDJmIYDaoQ5zuwyxnfj.html
    //-->Check if a subarray of size K exists whose elements form a number divisible by 3
    // C++ implementation of the above approach
    #include
    using namespace std;
    // Function to find the
    // K size subarray
    void findSubArray(vector arr, int n, int size)
    {
    pair ans;
    int i = 0, j = 0, sum = 0;
    bool found = 0;
    while (j < n)
    {
    sum = sum + arr[j];
    if (j - i + 1 < size)
    {
    j++;
    }
    else if (j - i + 1 == size)
    {
    if (sum % 3 == 0)
    {
    ans = make_pair(i, j);
    found = true;
    break;
    }
    sum = sum - arr[i];
    i++;
    j++;
    }
    }
    // If no such subarray is found
    if (found == 0)
    ans = make_pair(-1, 0);
    if (ans.first == -1)
    {
    cout