Sequential Digits | 2 Approaches | Leetcode 1291

Sdílet
Vložit
  • čas přidán 31. 01. 2024
  • Whatsapp Community Link : www.whatsapp.com/channel/0029...
    This is the 81st Video of our Playlist "Array 1D-2D : Popular Interview Problems".
    In this video we will try to solve a very good Array Enumeration problem - Sequential Digits | Leetcode 1291
    I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
    We will do live coding after explanation and see if we are able to pass all the test cases.
    Also, please note that my Github solution link below contains both C++ as well as JAVA code.
    Problem Name : Sequential Digits | Leetcode 1291
    Company Tags : AMAZON
    My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
    Leetcode Link : leetcode.com/problems/sequent...
    My DP Concepts Playlist : • Roadmap for DP | How t...
    My Graph Concepts Playlist : • Graph Concepts & Qns -...
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : / @codestorywithmik
    Instagram : / codestorywithmik
    Facebook : / 100090524295846
    Twitter : / cswithmik
    Approach-1 Summary : The first approach utilizes a queue to generate sequential digits in a breadth-first manner. It starts by enqueueing digits from 1 to 8 and then iteratively dequeues a digit, checks if it falls within the given range, and adds it to the result vector. Additionally, it enqueues the next sequential digit formed by adding one to the last digit of the current dequeued number. This process continues until the queue is empty, and the result vector contains all sequential digits within the specified range.
    Approach-2 Summary : The second approach uses a precomputed list of all possible sequential digits up to nine digits in length. It then iterates through this list, filtering out numbers that are below the given low value and above the high value. The result vector is populated with the filtered numbers.
    ╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    ✨ Timelines✨
    00:00 - Introduction
    #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear

Komentáře • 58

  • @ramanthakur2482
    @ramanthakur2482 Před 5 měsíci +14

    my day doesn't complete before watching your POTD video....ur way of teaching is quite amazing

  • @user-ub2is4rs4x
    @user-ub2is4rs4x Před 5 měsíci +6

    Bhai travel k waqt video upload. Salute to your dedication 🔥❤️

  • @souravjoshi2293
    @souravjoshi2293 Před 5 měsíci +7

    " bhai bhai approach" was awesome 🤣

  • @LakhanRathod1242
    @LakhanRathod1242 Před 5 měsíci +12

    Are bhai bhai bhai approach 🤣🤣🤣🤣

  • @AnjuGupta-sz1uk
    @AnjuGupta-sz1uk Před 5 měsíci +1

    Both approaches are very clear

  • @karanthakur11
    @karanthakur11 Před 5 měsíci +1

    method 1: slight change (change from recur memo to one based indexing) ese bhi likh skte hein recusrion memoisation ko
    method 2:: ise pehle tabulation
    slight change from tabulation to space optimization 33:44

  • @aryanraj9235
    @aryanraj9235 Před 5 měsíci

    last one was funny 😂😂,Are bhai bhai bhai...

  • @Trendspra
    @Trendspra Před 5 měsíci

    How can anyone explain programming logic so easily.....Hats off

  • @gauravbanerjee2898
    @gauravbanerjee2898 Před 5 měsíci +1

    thanks a lot bhaiya ❣❣ Hats off to your dedication🫡, providing videos even when you are travelling ❤❤

  • @wearevacationuncoverers
    @wearevacationuncoverers Před 5 měsíci +1

    waiting for you. ❣
    and hats off to your dedication.

  • @theOmKumar
    @theOmKumar Před 5 měsíci +2

    i solved it like this: brute force using sort
    vector sequentialDigits(int low, int high) {
    vector ans;
    for(int i = 1; i = low && res

  • @ankitpurohit7848
    @ankitpurohit7848 Před 5 měsíci +4

    Interviewer be like arayy bhai bhai bhai😂😂

  • @ankurtiwari9621
    @ankurtiwari9621 Před 5 měsíci

    I just waited for your video after trying..Thanks for your efforts becoming a big fan ..☺

  • @AnkitSingh-tm5dp
    @AnkitSingh-tm5dp Před 5 měsíci

    Best Explaination , Problem is also good i never do this type of problem of I have no idea of Intuition other then recursion.

  • @naveenkumarkota2090
    @naveenkumarkota2090 Před 5 měsíci

    keep making this videos will learn from u and we will be support mike

  • @Thriftinghai
    @Thriftinghai Před 5 měsíci

    dedication level 🔥🔥🔥🔥

  • @dipakdhakate5613
    @dipakdhakate5613 Před 5 měsíci

    bhai ka samzana like "so beautiful so elegant just looking like a wow"😅

  • @manimanohar_001
    @manimanohar_001 Před 5 měsíci +2

    Bro LC 1247 pe ek video pls🙏🙏🙏

  • @Mercer_077
    @Mercer_077 Před 5 měsíci +1

    13:23 First approach bhi toh O(1) hi time le rhi hai , n cant exceed 36 for given constraints.

  • @amitmehraa
    @amitmehraa Před 5 měsíci +2

    man you are awesome😂😂

  • @girdharipatel2
    @girdharipatel2 Před 5 měsíci +2

    are bhai bhai approach 😂

  • @codingdev4196
    @codingdev4196 Před 5 měsíci

    Hacker bhai 😂

  • @ugcwithaddi
    @ugcwithaddi Před 5 měsíci

    🔥🔥🔥

  • @aws_handles
    @aws_handles Před 5 měsíci

    Are bhai bhai bhai 😅👌🏻

  • @PiyushSingh-xg4mc
    @PiyushSingh-xg4mc Před 5 měsíci

    👌👌👍👍

  • @codeandtalk6
    @codeandtalk6 Před 5 měsíci

    ❤❤❤❤

  • @tutuimam3381
    @tutuimam3381 Před 5 měsíci +1

    ❤❤❤

  • @neerajchopra2758
    @neerajchopra2758 Před 5 měsíci +1

    sir please make gfg podt today question implement Atoi explanation 😭

  • @user-mc5ik4xh5p
    @user-mc5ik4xh5p Před 5 měsíci

    Bhai ek hi dil hai kitne bar jeetoge.
    Ab agar koi question apne nhi kiya hota youtube pe Mai kisi or ka dekhta hi nhi chor deta hu bad me karenge😂

  • @shreeramsingh7652
    @shreeramsingh7652 Před 5 měsíci +1

    sir, we need one detail video on while seeing any problem Constraints on any coding paltform by seeing the Constraints we should able to think which algorithm can apply and what its time complexity, Because i am seeing that in my class top coder are first he see question statement and directly they are seen Constraints and predict which algorithm i should apply ,they know basic cp, please kindly help us sir🙏🙏..

  • @lofireverbz-wy7go
    @lofireverbz-wy7go Před 5 měsíci

    bhaiya placement season aara hai june mai so please kuch new cheez le aoooo tadkta bhadakta like oops or something of your choice:)!!!!!

  • @Incredible2India
    @Incredible2India Před 5 měsíci

    2nd approch mst h 😂

  • @thefintechguy899
    @thefintechguy899 Před 5 měsíci

    "are bhai bhai bhai"

  • @manimanohar_001
    @manimanohar_001 Před 5 měsíci +1

    First view

  • @DreamPuller-cf6yl
    @DreamPuller-cf6yl Před 5 měsíci

    need guidance video for your videos

  • @Idk-qg7hb
    @Idk-qg7hb Před 5 měsíci +2

    I did bhai bhai approach 😂

  • @Shakib.Siddiqui
    @Shakib.Siddiqui Před 5 měsíci +2

    Bhai Bhai approach......is useful only for online assessment 😂

  • @bhuppidhamii
    @bhuppidhamii Před 5 měsíci +1

    waiting for today's potd

    • @codestorywithMIK
      @codestorywithMIK  Před 5 měsíci +1

      czcams.com/video/LvvIcZWtuoY/video.htmlsi=HUQTNEfDaAWQaqsc ❤️❤️😇😇

  • @thor1626
    @thor1626 Před 5 měsíci

    A sliding window approach which beats 100% users in java
    :
    class Solution {
    public List sequentialDigits(int low, int high) {
    String nums = "123456789";
    int lowerRange = 0, upperRange = 0;
    int lowerTemp = low, higherTemp = high;
    while (lowerTemp > 0) {
    lowerTemp /= 10;
    lowerRange++;
    }
    while (higherTemp > 0) {
    higherTemp /= 10;
    upperRange++;
    }
    List seqDigits = new ArrayList();
    for (int i = lowerRange; i = low && temp

  • @user-bc4hs4hp1u
    @user-bc4hs4hp1u Před 5 měsíci

    bhaiya pls try to upload this notes

  • @naveenkumarkota2090
    @naveenkumarkota2090 Před 5 měsíci

    like mardo sab log

  • @harshtiwari416
    @harshtiwari416 Před 5 měsíci

    bhai gfg ke count digits of a number ki bottom up video kab aayegi???

    • @user-ub2is4rs4x
      @user-ub2is4rs4x Před 5 měsíci

      I also am waiting . I think he is travelling and will upload when he is back.
      @codestorywithMIK - waiting

  • @priyanshugouravsarangi8553
    @priyanshugouravsarangi8553 Před 5 měsíci

    BFS FROM NOTHING HINT OF BFS FAIRS I THOUGHT OF DP FIRST

  • @sauravchandra10
    @sauravchandra10 Před 5 měsíci

    My approach:
    class Solution {
    public:
    long create(int start, int size){
    long res=start;
    for(int i=start+1;size>0 && i=low){
    ans.push_back(curNum);
    }
    }
    curSize+=1;
    }
    return ans;
    }
    };

  • @mohdzaid1158
    @mohdzaid1158 Před 5 měsíci +1

    are bhai bhai bhai approach 🤣🤣🤣🤣

  • @KumarMuravath-YearBTechChemica

    341 😳

  • @S3aw0lf
    @S3aw0lf Před 5 měsíci

    class Solution {
    public List sequentialDigits(int low, int high) {
    List result = new ArrayList();
    for (int i = 1; i

  • @sachinnarang2453
    @sachinnarang2453 Před 5 měsíci

    Beats 100%
    class Solution {
    public List sequentialDigits(int low2, int high2) {
    int count = 0;
    int low=low2,high=high2;
    while(low>0)
    {
    low/=10;
    count++;
    }
    int firstCount = count;
    count=0;
    while(high>0){
    high/=10;
    count++;
    }
    int secondCount=count;
    List lis = new ArrayList();
    for(int i=firstCount;i

  • @dhairyachauhan6622
    @dhairyachauhan6622 Před 5 měsíci +2

    i solved using digit dp but afterwards realized that the question was asking a vector. So there was nothing to memoize 🥲😁. But atleast this method is unique but complex and i dont know about the complexity but i guess it will be slower since i cannot memoize. Took my code (4ms)
    DIGIT DP (TEMPLATE)SOLUTION
    class Solution {
    public:
    void solve(string &R,int digit,int result,int prevDigit,int leading,bool tight,set&ans,bool erase){
    if(digit == 0){
    if(erase){
    ans.erase(result);
    return;
    }
    ans.insert(result);
    return;
    }
    int ub = tight?(R[R.length()-digit]-'0'):9;
    for(int i = 0;i