N-Queens Problem | using Backtracking | Leetcode Hard

  Рет қаралды 37,625

Apna College

Apna College

Күн бұрын

Пікірлер: 117
@thaneshgola1781
@thaneshgola1781 Ай бұрын
Consistency matters
@Praveen-G29
@Praveen-G29 Ай бұрын
Yes bro vo hi nhi ho pati
@thaneshgola1781
@thaneshgola1781 Ай бұрын
@Praveen-G29 make group of 3 members and give tasks to each other👍
@Praveen-G29
@Praveen-G29 Ай бұрын
@thaneshgola1781 yes bro ase hi karte ha but kabhi college ka kam ho jata ha ya abhi gar aa gye to consistency mentain nhi rahti
@abhimanyutiwari
@abhimanyutiwari Ай бұрын
@@thaneshgola1781 arthat ...
@clocktv1021
@clocktv1021 29 күн бұрын
Me web development kr rha hun daily so ye bhi krna chahiye kya
@animeshdubey941
@animeshdubey941 Ай бұрын
Extremely well explained but I would like to say your logic explanation is top notch nut please give more time in making us understand implementation of functions and like when you initialized that 2d strings. Please give more time on this. Hope u take constructive feedback thanks
@ayushburde1
@ayushburde1 Ай бұрын
yeahh initialization of boards right ? But yrr also we've to understand itna milraha h Ig that is enough baki GPT toh h hiii and also ye Recursion is bit tricky naa we need to give time to understand it thoroughly
@azcreation5353
@azcreation5353 11 күн бұрын
in isSafe function we don't need to check for horizontal as we are traversing through row only.so there will be no more than 1 queen in a row
@codeverse2
@codeverse2 Ай бұрын
I just realized, i have completed 46 videos of DSA series 😱
@tanishqvishwakarma9518
@tanishqvishwakarma9518 Ай бұрын
Done 👍 Thank you Didi 😊
@priyanshux_pro3373
@priyanshux_pro3373 Ай бұрын
More videos on this type ❤
@LeetCode-Satish
@LeetCode-Satish Ай бұрын
done thank you ma'am do bar lecture dekha maine abb pura samjh aa gya
@amarnarayandwivedi.358
@amarnarayandwivedi.358 Ай бұрын
mam your explaining way is superb
@saptarshiroy3326
@saptarshiroy3326 6 күн бұрын
Mam, we do not need to check for all the columns in a particular row while we are in "isSafe" function, beacuase while placing a new Queen there will be no previously placed Queens in that row. class Solution: def isSafe(self, board, row, col, n): ## Check for Queens in the column for i in range(n): if board[i][col] == 'Q': return False ## Check for Queens in the left diagonal above r = row-1 c = col-1 while r >= 0 and c >= 0: if board[r][c] == 'Q': return False r-=1 c-=1 ## Check for Queens in the right diagonal above r = row-1 c = col+1 while r>=0 and c < n: if board[r][c] == 'Q': return False r-=1 c+=1 return True def nQueens(self, row, ans, board, n): if row == n: ans.append(board.copy()) return for j in range(n): if self.isSafe(board, row, j, n): board[row] = board[row][:j]+"Q"+board[row][j+1:] self.nQueens(row+1, ans, board, n) board[row] = board[row][:j]+"."+board[row][j+1:] def solveNQueens(self, n: int) -> List[List[str]]: ans = [] board = ["."*n for _ in range(n)] self.nQueens(0, ans, board, len(board)) return ans
@ganeshjaggineni4097
@ganeshjaggineni4097 2 күн бұрын
NICE SUPER EXCELLENT MOTIVATED
@chhavi-thehelpinghand5281
@chhavi-thehelpinghand5281 Ай бұрын
Thanks mam you solve our many problems First comment
@wings9345
@wings9345 Ай бұрын
Great explanation ! ❤
@Socialmediaplatform0
@Socialmediaplatform0 Ай бұрын
Nice 🎉
@Totalvideoediting2.0
@Totalvideoediting2.0 Ай бұрын
Best 😊
@Shaswat_Shrivas
@Shaswat_Shrivas Ай бұрын
Lecture completed!
@rithik3958
@rithik3958 Ай бұрын
Hii queen solved 👸 queen problem ❤
@abhijeetthakur4537
@abhijeetthakur4537 27 күн бұрын
if the board is 2D then it should be like vector board;
@abhimanyutiwari
@abhimanyutiwari Ай бұрын
Awesome 🤩 hats off 🤠
@SaeedAjmal-k2d
@SaeedAjmal-k2d Ай бұрын
Thank you Apna collega for guide
@32rushya
@32rushya Ай бұрын
Lecture No.45 Complete ✅
@ASultani-mj1ee
@ASultani-mj1ee Ай бұрын
thank you Didi samaj gya.... after seeing 10 videos another
@nabin-x4f
@nabin-x4f Ай бұрын
Completed🎉🎉
@javeriamateen8260
@javeriamateen8260 Ай бұрын
great work 🥰🥰
@Codextron
@Codextron Ай бұрын
Great explanation!
@PrashChandra71
@PrashChandra71 Ай бұрын
Done Today lecture❤
@jyothiradithyag787
@jyothiradithyag787 14 күн бұрын
in the nqueens function your assigning ''Q' and ''.' with = assignment operator if some dummy put the comparsion operator there like me it will print infinte ''.'.So just be aware of that.
@azharalibhutto1209
@azharalibhutto1209 Ай бұрын
Great ❤❤❤
@mrsam07k
@mrsam07k Ай бұрын
Hello Shraddha Mam ☺️☺️
@ShreyaKaroddeo
@ShreyaKaroddeo Ай бұрын
Thank you ❤
@asnighoshdastider1971
@asnighoshdastider1971 Ай бұрын
Thank you so much!!!
@PiyushGupta-y3i
@PiyushGupta-y3i Ай бұрын
Thank you didee
@user-xw5kx1io8n
@user-xw5kx1io8n Ай бұрын
Thanks a lot for such content. Long Live. From Pakistan
@trexsagar4408
@trexsagar4408 12 күн бұрын
we can optimise it more like instead of wirting 4 loops we can write 3 loops for same col, upper-right diagonal, upper-left diagonal to check for the right place for queen code --> boolean isSafe(int n, char[][] board, int row, int col) { // check for same column above the current position for (int i = 0; i < n; i++) { if (board[i][col] == 'Q') return false; } // check for upper-left diogonal for (int i = row - 1, j = col - 1; i >= 0 && j >= 0; i--, j--) { if (board[i][j] == 'Q') return false; } // check for upper-right diagonal for (int i = row - 1, j = col + 1; i >= 0 && j < n; i--, j++) { if (board[i][j] == 'Q') return false; } return true; }
@VarunJain-ii1mn
@VarunJain-ii1mn Ай бұрын
Completed
@SxV_editz
@SxV_editz 29 күн бұрын
More videos plz mam ❤
@Sunnychaudhary5609
@Sunnychaudhary5609 Ай бұрын
done mam
@tanishqvishwakarma9518
@tanishqvishwakarma9518 Ай бұрын
# 50 videos milestones completed 🎉🎉🎉
@salmanmehmood470
@salmanmehmood470 Ай бұрын
Nice 🙂
@MdSahidReja19
@MdSahidReja19 4 күн бұрын
Completed on 28-01-25
@anandtiwari6596
@anandtiwari6596 Ай бұрын
Thanks didi
@pranaveditzzz8842
@pranaveditzzz8842 6 сағат бұрын
mam i think you tell wrong ,time complexity it is O(n*n!) .O(n!) will be there if we will done pruning but here we are not doing any pruning ig
@known-rr6pt
@known-rr6pt Ай бұрын
Hello di , Can you please make a road map video for students to become data scientists in 2025 like you made a video for web development
@amritverma5166
@amritverma5166 27 күн бұрын
mam, I am having trouble in recursion topic, I have completed all the previous videos as well but still I am not able to get the confidence.
@tanayprabhakar894
@tanayprabhakar894 Ай бұрын
didi aaj he ki DAA(Design and Analysis of Algo) ke exam mein mai ye likh ke aaya, I wish ye kuch der pehle aaya hota 🥹
@SatyamKumae-mw5fq
@SatyamKumae-mw5fq Ай бұрын
Ye program aya tha kya?
@Rexx-fj5wt
@Rexx-fj5wt Ай бұрын
Bai mara ajj haa😂​@@SatyamKumae-mw5fq
@ayushburde1
@ayushburde1 Ай бұрын
umm.. this was interesting one espcially how to place queens in safe zone
@InfoPanel7902
@InfoPanel7902 Ай бұрын
I can't understand why ans is of type vector and not vector Please help me
@iprosenjitp
@iprosenjitp Ай бұрын
Since the type of "board" is vector and we are storing "board" in "ans," the type of "ans" must be vector.
@InfoPanel7902
@InfoPanel7902 Ай бұрын
@iprosenjitp but ans could have been vector type and we could just put the value of board into ans
@iprosenjitp
@iprosenjitp Ай бұрын
@@InfoPanel7902 We may need to store multiple "board" values. That's why the type of "ans" is vector of vector.
@sahasantu
@sahasantu Ай бұрын
Since you are adding a single Q per row, what is the point of checking horizontal safety?
@prateekgupta2997
@prateekgupta2997 Ай бұрын
while the loop runs for the second queen q2 it shouldn't be placed at the q1 path , Or we can say that till all the queens are placed to their correct position i.e Q1,Q2,Q3,Q4 , we couldn't assume that the position of Q1 at the starting was correct until all are placed
@priyajangra6049
@priyajangra6049 Ай бұрын
Best
@AliKhan-l6l5z
@AliKhan-l6l5z Ай бұрын
2nd ❤
@DipAhmed1010
@DipAhmed1010 Ай бұрын
❤❤❤
@Ravi_Negi
@Ravi_Negi Ай бұрын
Madam plz.. Make a video on 2025 which field Boom
@krishnakumar-iz4xh
@krishnakumar-iz4xh 9 күн бұрын
day 38 lecture 45 completed
@UnderGradPlayers
@UnderGradPlayers Ай бұрын
First comment ❤
@HrishabhPatel09
@HrishabhPatel09 Ай бұрын
Code Here: class Solution { public: bool checkHorizontal(int row,vector &board){ int n = board.size(); int count = 0; for(int j=0;j=0){ if(board[i][j]=='Q')count++; i--; j--; } // bottom-right check i = row+1; j = col+1; while(i
@chaitanyakhare1869
@chaitanyakhare1869 Ай бұрын
completed 26 dec
@divyanshuraj004
@divyanshuraj004 Ай бұрын
Ma'am ek c++ ka v video banayea
@jyothiradithyag787
@jyothiradithyag787 14 күн бұрын
17th Jan
@Raghu-r9
@Raghu-r9 Ай бұрын
👏
@LL16YT
@LL16YT Ай бұрын
Kya timing hai...kaal exam hai mera iss topic ka
@abhijeetthakur4537
@abhijeetthakur4537 27 күн бұрын
kon se semester me ye question puch rha h bhai , mazak me mt lena sach me puch rhe hn
@sandeepmehta-e9l
@sandeepmehta-e9l Ай бұрын
present didi
@Crazyconsole-786
@Crazyconsole-786 Ай бұрын
Mam why are 4 videos are hidden in this playlist
@ROHITKUMARSENAPATI-mu7zt
@ROHITKUMARSENAPATI-mu7zt Ай бұрын
@yogeshbhatt3440
@yogeshbhatt3440 Ай бұрын
👏👍👍👍👍
@Goldy-w3z
@Goldy-w3z Ай бұрын
5/12/2024 lecture 45 completed!
@Learntonew123
@Learntonew123 Ай бұрын
Didi SAP ABAP par ek video banaye please
@ayushijain1451
@ayushijain1451 Ай бұрын
playlist m 4 videos are hidden likha aata h..what this means????
@RajibRoy-u1o
@RajibRoy-u1o Ай бұрын
Mam Amazon me job pane ke liye age limit kya hai
@shwetakumari1002
@shwetakumari1002 28 күн бұрын
lecture 45 completed on 4th jan
@fejanansari8416
@fejanansari8416 Ай бұрын
First ❤
@Crazyconsole-786
@Crazyconsole-786 Ай бұрын
Mam can you please upload videos with in a gap of 1-2 days please
@headempire2865
@headempire2865 Ай бұрын
37th
@kiransoni8712
@kiransoni8712 Ай бұрын
Day 47 05-12-24😊😊
@AtharvTIWARI-ce6oq
@AtharvTIWARI-ce6oq Ай бұрын
hello I am second
@HardikAgarwal-v5b
@HardikAgarwal-v5b Ай бұрын
Mam lecture thode jaldi jaldi upload karo Kab tak complete karoge
@HarshSharma-fz6of
@HarshSharma-fz6of Ай бұрын
Why did she left microsoft.
@Createfilmclip
@Createfilmclip Ай бұрын
Shraddha didi please hame 11 class me acha score karne ke liye kya kare please didi ispe aap video jarur banana 😊😊😊❤❤❤
@sayanbera7922
@sayanbera7922 Ай бұрын
First 🥇
@rajeevyadav4802
@rajeevyadav4802 18 күн бұрын
Ma'am backtracking me thoda doubt hai
@Haider_ALI_14-s7d
@Haider_ALI_14-s7d Ай бұрын
I'm 1st viewer.
@kashishjuneja5214
@kashishjuneja5214 Ай бұрын
29/12/24
@Rahulyadav-x2c1b
@Rahulyadav-x2c1b Ай бұрын
I am first😮
@anupamsrivastava523
@anupamsrivastava523 Ай бұрын
hey i am 4th year ECE student i have studied theoretical subjects but haven't coded DSA problems althaugh i have studied DSA theory and stuff in university, i need to be placed by january , i have no projects in ML or any other subject can someone tell me what to do.pls i am un need for some guidance. what to study right now and what field to aim for.
@asksaishree5444
@asksaishree5444 Ай бұрын
Hi
@sangamkhanna
@sangamkhanna Ай бұрын
Dii aaj hi DAA ka exam de k aaya hu…thodi late hogye😭😭
@mdfarhan5364
@mdfarhan5364 Ай бұрын
attendance 45
@ApurvSahu-s4m
@ApurvSahu-s4m Ай бұрын
completed 12/10/2024
@Aliens.report
@Aliens.report Ай бұрын
1st
@Learntonew123
@Learntonew123 Ай бұрын
Sap ABAP class
@cheetawarrior524
@cheetawarrior524 Ай бұрын
Now I have realized how dumb I am
@AK.SAHB01
@AK.SAHB01 Ай бұрын
i am pakistani
@Dasvimal001
@Dasvimal001 Ай бұрын
Jaldi jaldi like comments kr dete hai like mileagA😂😂
@VishnuSingh_vb
@VishnuSingh_vb Ай бұрын
Good night 🌃😂
@abhijit_pandit
@abhijit_pandit Ай бұрын
Mam plz Java dsa KZbin par padhaye. Plz❤❤❤❤❤❤❤ koun koun chahta hai
@AnshKashyap-v6u
@AnshKashyap-v6u Ай бұрын
Kon kon baith kar like or views dekh raha hai...😅
@YouTub-f3c
@YouTub-f3c Ай бұрын
1st comment 😊
@animeshdubey941
@animeshdubey941 Ай бұрын
Extremely well explained but I would like to say your logic explanation is top notch nut please give more time in making us understand implementation of functions and like when you initialized that 2d strings. Please give more time on this. Hope u take constructive feedback thanks
@AkankshaPawar-p7g
@AkankshaPawar-p7g Ай бұрын
Completed 👍
@AK.SAHB01
@AK.SAHB01 Ай бұрын
best
@narsimharao8565
@narsimharao8565 Ай бұрын
@animeshdubey941
@animeshdubey941 Ай бұрын
Extremely well explained but I would like to say your logic explanation is top notch nut please give more time in making us understand implementation of functions and like when you initialized that 2d strings. Please give more time on this. Hope u take constructive feedback thanks
Sudoku Solver Problem | using Backtracking | Leetcode Hard
26:58
Apna College
Рет қаралды 29 М.
Palindrome Partitioning Problem | Recursion & Backtracking
20:44
Apna College
Рет қаралды 18 М.
N-Queens - Backtracking - Leetcode 51 - Python
17:51
NeetCode
Рет қаралды 191 М.
6.1 N Queens Problem using Backtracking
13:41
Abdul Bari
Рет қаралды 2,2 МЛН
Sort an Array of 0s, 1s & 2s | DNF Sorting Algorithm | Leetcode 75
33:39
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 826 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 214 М.
Subarray Sum Equals K | Brute-Better-Optimal approach
34:45
Apna College
Рет қаралды 30 М.
I Found A Secret Database Of Recruiter Rejection Reasons
9:18
Rahul Pandey
Рет қаралды 60 М.
Rat in a Maze Problem | Backtracking
32:45
Apna College
Рет қаралды 27 М.