Ep21 - N Queen | Recursion | DSA series by Fraz | Notes available in description

Поделиться
HTML-код
  • Опубликовано: 5 янв 2025

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

  • @spanningtree5869
    @spanningtree5869 2 года назад

    Thanku bhaiya 🥰🥰😊❤

  • @divyanshsagar
    @divyanshsagar 2 года назад

    Recursion playlist done!

  • @ratnasanjay
    @ratnasanjay 2 года назад

    Thankyou bhaiya for this nice session

  • @ShivamKumar-kx3rx
    @ShivamKumar-kx3rx 2 года назад

    loving the videos bhaiya loving them

  • @priyanshusingh8971
    @priyanshusingh8971 2 года назад

    yo lectures top notch

  • @priyanshjha6952
    @priyanshjha6952 2 года назад

    Completed, no days missed 21/21 days.

  • @Gauravkumar-kc6xh
    @Gauravkumar-kc6xh 2 года назад

    Great

  • @sujalgupta6100
    @sujalgupta6100 2 года назад

    Completed whole series.

  • @divyanshsagar
    @divyanshsagar 2 года назад

    Ha Bhaiya kaafi help mil rahi hai lectures se bas kuch lectures me yeh to samaj aa jaata hai solution kya hai par line by line code asli me kaise work kar raha hai usme dikkat aa jaati hai isliye agar aap dry run bhi karwa do to wo bhi problem solve ho jaaegi.
    PS: Your content is 🔥🔥

    • @LearnYardYT
      @LearnYardYT  2 года назад +1

      Okay bro karenge ye bhi try, till then you try to do the Dry run with pen and paper

    • @divyanshsagar
      @divyanshsagar 2 года назад

      @@LearnYardYT Ok bhaiya ✌️

  • @yeswanthh5068
    @yeswanthh5068 2 года назад +1

    💚💚💚

  • @simantsaurav2350
    @simantsaurav2350 2 года назад

    Misson passed, respect ++ 😎

  • @aadarshpandey2793
    @aadarshpandey2793 2 года назад

    Got everything about the Queen Problem
    Thanks sir

  • @GM-pk4li
    @GM-pk4li 2 года назад

    it's better than coding ninjas courses

  • @CodeandColors22
    @CodeandColors22 2 года назад

    Yes bhiyaa apki consistency or apki mhnt dikhti hai fr chahe LL ho yah recursion help or understanding clear hoti hi h i follow you ajay ki placement se you are very hardworking ❤🥰

  • @divyakeshri7377
    @divyakeshri7377 2 года назад

    Well explained 💯🔥

  • @jameschennaicho860
    @jameschennaicho860 2 года назад

    Gr8 explaining 🙏❤️

  • @alokbind3305
    @alokbind3305 2 года назад

    Well explained✨🙌

  • @divyabaghel5076
    @divyabaghel5076 2 года назад

    thank you for amazing lectures

  • @sanketbhagat1222
    @sanketbhagat1222 2 года назад

    Thankyou so much bhaiya for your content.

  • @it_08amanagarwal35
    @it_08amanagarwal35 2 года назад

    Lots of love and looking forward to learning new questions ❤❤❤❤❤❤❤❤❤❤❤

  • @Abhishek-fo3fc
    @Abhishek-fo3fc 2 года назад +1

    Done understood ❤️✅

  • @its_Akash_
    @its_Akash_ 2 года назад

    Consistency++ sir

  • @sonicboom6635
    @sonicboom6635 2 года назад +1

    Very well explained 😊

  • @emtiazahmed5333
    @emtiazahmed5333 2 года назад

    Mid night class😁😁 thank u bhaiya😝

  • @arghya_0802
    @arghya_0802 2 года назад +4

    Summary:
    1. We need to place N Queens in N*N chessboard. That means we can only place only one Queen in every row. We cannot skip any row else we cannot solve it. We need to return all possible solutions by placing queens in different positions throughout the chessboard.
    2. Queens can cancel each other - in same row , in same column, in left diagonal(both up and down) and in right diagonal(up and down). However, as we are placing 1 Queen in every row so we don't need to check for rows. Also, as we are filling our chessboard in up to down manner , we don't need to check for down Left Diagonal and Down Right Diagonal respectively,
    3. Instead of checking everytime in the column or Upper Left or Right Diagonal respectively, we can use 3 separate arrays/vectors of length n to check if placing a queen at (i,j) in the board is safe or not. The mapping goes as follows:
    a) for columns: a simple array where cols[i] = 1 if Queen is placed else cols[i] = 0 is sufficient.
    b) for Upper Right Diagonal: we map using (row + col) with index of UpperRight vector, that is, in our Upper Right Diagonal array UpperLeft[currentRow + currentCol] = 1 if Queen is present in the Upper Right Diagonal of (currentRow, currentCol) else it will be 0.
    c) for Upper Left Diagonal: we map(row - col + n - 1) with index of UpperLeft vector. If Queen is present UpperLeft[i] = 1 else it will e 0.
    4. Now our task is pretty easy. If our row == n, it means we have successfully placed all N-Queens in the chessboard, so we save our current configuration of the board in our vector and and return back.
    5. Otherwise, we will iterate over all the columns from 0 till n-1 using a for loop and see where we can place a Queen in currentRow or i-th row.
    6. For check we will declare a isSafe() function which takes currentRow , currentCol, cols[] , UpperLeft[] and UpperRight[] vectors. Or we can simply iterate over all the columns of currentRow , and check the diagonals as well. Whichever suits us better we can use it.
    7. Lastly, whenever isSafe() returns true, we will place the Queen at that location and ask recursion to place rest of the Queens starting from next Row thatis, currentRow + 1.
    8. At the end, we return our and[][] from the given function, which contains all possible N-Queens solutions.
    Time Complexity: O(N!) [ As Fraz sir has explained, at first row we are having N choices, in the next row, we will be having (N-1) choices and in the next to next row, we will be having (N-2) choices at max ... which roughly calculates to N! ways. So Time Complexity is O(N!)
    Space Complexity: O(N) [ Only recursive stack space] & O(N^2) [if we consider our vector and containing all valid configurations] {The Height of recursive tree will only be equal to N(number of Queens) but if we consider all the our and[][] vector containing all valid configurations then our Space Complexity is O(N^2). Generally, we always consider the Auxiallary Stack Space or any other data structures we use by our own but it's always better to explain all the complexities to the Interviewer !!
    P.S.: The use of cols[] , UpperLeft[] and UpperRight[] just blew my mind up. Very few Ytbers will actually explain both logics. Thank you sir for making such awesome videos!!!

  • @bhuneshmeravi8411
    @bhuneshmeravi8411 2 года назад

    this lecture is really difficult than previeus one😀

  • @it_08amanagarwal35
    @it_08amanagarwal35 2 года назад

    Bro Main thing about ur whole Lectures of recursion is way of teaching each concept in a simple way so that everyone can understand and one who nows the question will also get a new concept for question

  • @Lucifer-xt7un
    @Lucifer-xt7un 2 года назад +14

    Just don't miss consistency bro one day you will get break and this will be one stop for placement preparation

  • @vivekpaanchal
    @vivekpaanchal 2 года назад +1

    Bhaiya leetcode ke questions kyu nhi karate 🥲🤧

  • @RitikSINGH-ts4cx
    @RitikSINGH-ts4cx 2 года назад

    At 29.47 u have made a recursion tree and here you have explained the time complexity as n! Which seems fine but I have one doubt if I shall made a recursion tree of string permutations then it should be also like this like n+(n*n-1)+(n*n-1*n-2)+................+n-1!+n! Then there n! Should be the time complexity but u said there n*n!
    Kindly answer this.it shall be a great help
    @Lead Coding by FRAZ

    • @brahmkaransingh8804
      @brahmkaransingh8804 2 года назад

      here we have for first n options to place ,for second n-1, for third n-2 and so on which is same to permutations ques thus n! factor is same in TC . But an extra n was there because at every stage we were having a string of length n but here we are just putting 0 and 1 . Hope this solves your doubt. Questions are most welcome

  • @nitinkale4985
    @nitinkale4985 2 года назад

    I will be watching this video tomorrow, I am already feeling confident when it comes to recursion. I think I am elder than you, but I will still call you fraz bhaiyya. Thank you so much bhaiyya for this playlist....

  • @jayantmishra6897
    @jayantmishra6897 2 года назад +2

    today i have completed this whole series now i am feeling confident in recursion and waiting for the dynamic programming series .thank you sir

  • @aasifali9139
    @aasifali9139 2 года назад +3

    Thanks fraz bhaiya for these awesome lectures. I don't have enough words to thank you for the efforts you have put in your videos.
    Now i am feeling confident in Recursion, earlier i used to fear from recursion.
    Thanks again for removing my fear.

  • @himanshmishra5398
    @himanshmishra5398 2 года назад

    Great bhaiya this consistency motivates me a lot

  • @DeepakKumar-jg1xk
    @DeepakKumar-jg1xk 2 года назад

    Waiting for next video bhaiya , loving this series bhaiya 🥰

  • @092mohammadkudratullah6
    @092mohammadkudratullah6 2 года назад

    Very hard work 👌

  • @it_08amanagarwal35
    @it_08amanagarwal35 2 года назад +2

    Excellent Lecture bro hoping for many more good lectures❤❤❤❤❤❤❤❤❤❤❤❤

  • @abhay.1926
    @abhay.1926 2 года назад

    Present sir🙌🙌

  • @BurhanAijaz
    @BurhanAijaz 2 года назад

    came from telegram as u asked for it, i have been watching ur videos regularly but i am not able to solve different questions from different platforms

  • @HarshitSharma-si4wl
    @HarshitSharma-si4wl 2 года назад

    this series is beneficial for me, I am daily excited about new video

  • @Lucifer-xt7un
    @Lucifer-xt7un 2 года назад +6

    Experiencing the pure knowledge with unmatchable consistency ❤️❤️

  • @mohdsaadalikhan7209
    @mohdsaadalikhan7209 2 года назад

    space complexity should be : N (recursion stack space) + N^2 (chessBoard) + N! (valid configurations stored in ans vector as there can be N! possible configurations) ???????????????

  • @CodeandColors22
    @CodeandColors22 2 года назад +1

    Salute your hardwork bhiyaa 🥰❤

  • @GrowWithSaksham
    @GrowWithSaksham 2 года назад

    Which software do you use for teaching?
    Please tell me🙏🏻

  • @sonimuskan5234
    @sonimuskan5234 2 года назад +5

    though i have solved these questions already, still there is something new to learn from u each day

  • @budhadityachatterjee6270
    @budhadityachatterjee6270 2 года назад

    Thank you !

  • @ChandanKumar-ph8dl
    @ChandanKumar-ph8dl 2 года назад

    Consistency break ho gyi this 10 k baad , abhi 16 per huun....
    Soon will catch you.

  • @rushilranjan172
    @rushilranjan172 2 года назад

    Thanks for making these videos definitely getting a hang on recursion

  • @samqureshi9415
    @samqureshi9415 2 года назад

    Dsa toh kar lege per offcampus interview Lena muskil hai .

    • @LearnYardYT
      @LearnYardYT  2 года назад

      Why bro

    • @samqureshi9415
      @samqureshi9415 2 года назад

      @@LearnYardYT I did bsc cs or jab mai job search karne laga toh koi bhi 15k se 20k ki salary dera sirf yea lakhs wali salary toh sirf sapna ban kar reh gaya hai.

  • @mohdumar6990
    @mohdumar6990 2 года назад +2

    Your explanation is very awesome.
    No need to remember code 😄.
    Create code by deriving the problem

  • @Wanna_be_01
    @Wanna_be_01 2 года назад

    Thanks #Fraz_Bhaiya for this video ❤️🔥
    Mera Ek Problem ho rha hai pta hi nhi chal rha hai ki kaun sa question me kaun sa DS use karun.
    Ya question ke phle pura DS Revision karun.
    Can anyone tell me what should I do?

    • @LearnYardYT
      @LearnYardYT  2 года назад +1

      Start with this series fir uske baad aage karna

    • @Wanna_be_01
      @Wanna_be_01 2 года назад

      @@LearnYardYT Haan Bhaiya!!
      ye to main starting se kaar rha hoon lekin Leet Code ke Problems nhi ho rhe hai mere se 😥
      Phir depressed 🤦‍♂️ bhi ho jata hoon ki mere se kyo nhi ho rhe.🤕

  • @mohdumar6990
    @mohdumar6990 2 года назад

    Good and easy explanation

  • @paawansingal788
    @paawansingal788 2 года назад

    These recursion videos are very helpful. Thankyou so much for all your hard work.

  • @gauravkumar3036
    @gauravkumar3036 2 года назад +4

    Consistency++
    It's 2:00 am now, salute to your hardwork🌟

  • @prashantsingh3618
    @prashantsingh3618 2 года назад +3

    Thank you for being consistent with videos bhaiya!

  • @DeepakKumar-jg1xk
    @DeepakKumar-jg1xk 2 года назад +1

    Present Sir , waiting for this today 🥰

  • @souvikmukherjee8419
    @souvikmukherjee8419 2 года назад

    A work of art by an artist........ fantastic video bhaiya👌bahut achhe seh samaj aya

  • @jasmin_bheda
    @jasmin_bheda 2 года назад +1

    I don't know if you gonna see this or not but faraz bhai thank you so so so much man, I don't know how to explain this but I was so much stuck in Recursion and literally gave up on this topic but I found somewhere on twitter lately about your Recursion playlist so thought about giving it a try & man It was one of the best decision I had ever made. Thank you so so much brother U don't even know how many people's lives your work is changing God Bless You Brother May You always be Successful ❤❤(also bhaiya if if possible start a new series as well It will be really really helpful ... : ) )

  • @brobasticdoooooooom4467
    @brobasticdoooooooom4467 2 года назад

    All the lectures are really good and am able to understand and build a strong base. Since there is less time left for placement now, could you also provide us how we can cover more topics soon?

    • @LearnYardYT
      @LearnYardYT  2 года назад

      Yes I am trying but thoda sa time ka issue hai due to full time job

    • @brobasticdoooooooom4467
      @brobasticdoooooooom4467 2 года назад

      @@LearnYardYT yes understandable bhaiya, and it’s such a great thing that you are doing for us simultaneously with your work, Truly an inspiration. Thanks a lot!

    • @brobasticdoooooooom4467
      @brobasticdoooooooom4467 2 года назад

      @@LearnYardYT not videos but could you provide a roadmap or resources where we can start learning others topics side by side as well?

  • @BurhanAijaz
    @BurhanAijaz 2 года назад

    Day 21 kya hi likhu kyuki kal dekha nahi, but kuch dino pehle leetcode pai kia tha maine same question,so i don't regret anything but u still uploaded the video at about 2am , that's the consistency 🔥

  • @mohdumar6990
    @mohdumar6990 2 года назад

    Consistency++

  • @doremondis2891
    @doremondis2891 2 года назад

    When is next topic coming ?

  • @surgeonofdeath8199
    @surgeonofdeath8199 2 года назад

    hey bhaiya a little off topic question but plzz do help me
    so i was doing question leetcode (my daily practice) and i countered a problem which i wasn't able to solve but when i saw the solution i was able to understand it easily this is not the first time this thing has happened to me
    so my question is what to do in this scenario really confused should i just keep going like this..?

  • @mdsufyankhan1029
    @mdsufyankhan1029 2 года назад

    As usual cool lectures..
    Never gonna bored on your voice
    Keep making ,and take this ❤️

  • @abhishekc3556
    @abhishekc3556 2 года назад

    🔥🔥

  • @mohammedsaqib1250
    @mohammedsaqib1250 2 года назад

    Bhai ek baar doubt session rakh ke recursion ki time complexity aur space complexity explain kardo bahuth dikkat ho rahi hai calculate karne me kuch bhi samj nai aaraha hai time and space complexity calculate karne me

  • @Mevinaygupta
    @Mevinaygupta 2 года назад

    Sorry but I am not able to be consistent .I don’t know c neither java but I am working javaScript which language should I go with and I am working in industry for around 2year and I build stuff in service based company but really wana switch to products based company .so for this complicated mess I shared here but I really wana admit my issue . If any one have any suggestions for me .please share me here

    • @LearnYardYT
      @LearnYardYT  2 года назад

      I will put hava script codes in description

  • @DPCODE72
    @DPCODE72 2 года назад

    #include
    Using namespace std;
    Int main(){
    While(1){
    Printf(" Fraz bhaiya consistency & dedication ");
    }
    Return 0;
    }
    Ur dedication & hard work motivate me all the time to keep moving!!
    Thnaks alot for everything ur!!
    #FrazbhaiyaConsistency

  • @Shorts_Music_74
    @Shorts_Music_74 2 года назад

    🔥❤️❤️🔥

  • @HarshRaj-kp7gk
    @HarshRaj-kp7gk 2 года назад +1

    Sir , you videos are amazing 🙏🏾🙏🏾
    And one suggestion you donot think about views in video in long term your video going to rock on ytube
    Sir , ek questions ke sheet bna digiye ga verbal ability , aptitude and resonaning ka 🙏🏾🙏🏾( for placement) including ytube video link also

  • @eishapilkhwal4872
    @eishapilkhwal4872 2 года назад +3

    Great explanation bhaiya. Waited for your DSA Series so long. I personally likes your style of teaching and recommended my batchmates to follow your series. Feels demotivated many times but your consistency motivates me.
    Thank you Bhaiya
    Stay happy hamesha.