Implementing Recursion Ideas into Code | Day 1 Part 2 | Dynamic Programming workshop | Vivek Gupta

  Рет қаралды 26,368

Vivek Gupta

Vivek Gupta

Күн бұрын

Пікірлер
@codingwithanonymous890
@codingwithanonymous890 2 жыл бұрын
that diagonal check using absolute value of previous and current row/column was mindblowing...O(1)
@amandixit8342
@amandixit8342 2 жыл бұрын
yeah beacause ek hi loop mein teeno possiblities check kar de raha , jab mene ye dekha 2-3 friends ko aur batya dekh bhai aise b ho skata no need to 3 loop for checking , it's really good approach :)
@harshupreti1526
@harshupreti1526 2 жыл бұрын
Yes checking of the slope
@soumyadeepdash4805
@soumyadeepdash4805 2 жыл бұрын
You can also do the whole check function in O(1) using three arrays, 1st array is to check whether we can place the queen in this column, 2nd one is for left diagonal and 3rd is for right diagonal. Indexing of left diagonal => n-row+col,,,, right diagonal => (2*n-1)-row-col. Also u have to update these arrays when placing queens.
@vivekgupta3484
@vivekgupta3484 Жыл бұрын
@@soumyadeepdash4805 True. infact even faster approaches exist like keeping this diagonals in bitmask and taking & to find possible positions in O(1) ... thats even faster... but let's keep things to limit for now.
@radicalengineer2331
@radicalengineer2331 2 жыл бұрын
This is one of the most optimal ways to solve with a framework bhai ko as if pata hai ki exactly kidhar we'll get stuck and he has shown us the way to think on that using his LCCM method Super bhai
@utkarshpandey6600
@utkarshpandey6600 6 ай бұрын
diagonal trick is came from mathematiics slope formula, as we know diagonal are at an angle of 45 degree , so tan 45 is 1. then our formula will become like that condition
@AmanTheMystery
@AmanTheMystery 2 жыл бұрын
that diagonal check trick is awesome....that why if some one knows recursion still i said to watch vivek sir videos u will get new things in your bag
@CodeChamp-tw8ho
@CodeChamp-tw8ho 3 ай бұрын
great problems and a lot to learn!!💻💻
@anjumankhan1593
@anjumankhan1593 2 жыл бұрын
Super easy to understand with LCCM method!!!
@CREATIONTIME1
@CREATIONTIME1 7 ай бұрын
why this video is not getting millions views.. this is the best explanation..
@abhishek04204
@abhishek04204 2 жыл бұрын
dont know how you manage the recording and your job thank you for the videos
@Sandeep-zd6dq
@Sandeep-zd6dq 2 жыл бұрын
Loved this video, specially the check to place the queen till now I was always writing 3 loops in my check function 😂
@akshatmehra3951
@akshatmehra3951 2 жыл бұрын
Maze aa gye bro 🔥N-Queens ekdum samajh aa gya. Thanks a lot for the good work, keep it up 👍🏼 full support
@socify4410
@socify4410 6 ай бұрын
absolute mindblowing
@leftover19
@leftover19 2 жыл бұрын
Hii sir, my friend gave me your algozenith course and another friend (6* on codechef) told me to learn dp from here. When I heard your voice i was like 🤯🤯 this man. All I want to say is your explanation is very elaborate and easy to understand. Never understood dp this way. Thanks for the effort.,❤️
@noone0978
@noone0978 5 ай бұрын
note for me: see, the approach i can think for last problem is that we will declare penalty as global variable starting from zero, then we will write the rec function with level starting from zero and going till n and we will declare n as k+1, we will also make an array of size k+1 which will store the area of each part because k tear will result in k+1 parts, when the base case will hit that is level==n, then we will find penalty=min(penalty, current penalty) where current penalty will be sum of square of elements of array, now for the tear part that how we will tear, what i thought was we will use two recursion loops, one will tear horizontally and other will tear vertically this is not complete but this was my first thought hit in 2 minutes after seeing the problem
@Sandeep-zd6dq
@Sandeep-zd6dq 2 жыл бұрын
Bro ye shi tarika hai video ko question k saath end krne ka 😂 ab ruka hi nhi jaa rha isko solve toh krke rahunga 😎 because it’s a new question for me 🔥
@AshishKumar-cw9xw
@AshishKumar-cw9xw Жыл бұрын
Can u please send the solution of last problem
@AdityaPradhan-f2p
@AdityaPradhan-f2p 4 ай бұрын
24:05 Wow!
@smile_please5848
@smile_please5848 2 жыл бұрын
can anyone explain what we are doing at 22:49 ,how we are saving the position of previous queens?
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
the queens array is global and is being shared across … and in recursion it is being filled
@sachitsankhe5102
@sachitsankhe5102 2 жыл бұрын
Amazing Day-1
@saranghae3720
@saranghae3720 2 жыл бұрын
last problem is based on dp on partition, as we can cut at any co-ordinate of the grid. Correct me, If I'm wrong.
@akshayshah7008
@akshayshah7008 2 жыл бұрын
Hey Vivek, Everytime writing the base case first is necessary or how do you think when it comes to base cases?
@ArnabJhaYT
@ArnabJhaYT 2 жыл бұрын
very beautiful code
@shriyanshjain4444
@shriyanshjain4444 2 жыл бұрын
33:18 I understand the logic explained but line 38 and 40 inside if check confuses me still. Can anyone help?
@abhishekc3556
@abhishekc3556 2 жыл бұрын
Line 38 is suppose if you've placed a queen at the current level / row you're at, then you do rec(level + 1) meaning after you've placed the queen at current row, you're asking the recursion to go to the next level / row and place queens there if possible. Line 40 is suppose you have a 8*8 board and you place a queen on the 0,0 coordinate. Assume the total number of possible configurations is x if you've placed the queen on the 0,0 coordinate. Now the question wants you to compute the total number of cases right. So now you'll place a queen on 0,1 coordinate and try to find all possible configurations but before you place a queen on 0,1 you need to remove the queen you had placed on 0,0. That's why on line 40 we remove the queen that was previously placed
@abhishekc3556
@abhishekc3556 2 жыл бұрын
I'd recommend to go through striver's recursion playlist. He's explained recursion beautifully
@MCAAARULMishra
@MCAAARULMishra 2 жыл бұрын
@@abhishekc3556 can you please explain why he said LINE40 is not need for this problem at 26:34
@shriyanshjain4444
@shriyanshjain4444 2 жыл бұрын
@@abhishekc3556 sure will check that
@abhishekc3556
@abhishekc3556 2 жыл бұрын
@@MCAAARULMishra just watch takeUForward's nqueen problem once and even then if you don't understand, I'll explain.
@AKASHKUMAR-li7li
@AKASHKUMAR-li7li 8 күн бұрын
in que 3 why we have not taken the values itemTaken and timeTaken along with recursive calls.....?
@Profnegi
@Profnegi 10 ай бұрын
N-queen best: i've done this by myself after watching the video (in leetcode there is more on this problem )
@utkarshpandey6600
@utkarshpandey6600 6 ай бұрын
i 3rd question , how ans will return our real maximum skill, in whole code we do not did anything to it. and how answer return.
@vivekgupta3484
@vivekgupta3484 6 ай бұрын
Time stamp exactly?
@noone0978
@noone0978 5 ай бұрын
in 3rd problem that skill one, you didn't used loop, but can we iterate over all n and then check if it satisfies or not instead of using 2 recursive calls, like one for loop and one recursive call inside that for loop?
@Abhishek-fo3fc
@Abhishek-fo3fc 2 жыл бұрын
DAY 1 PART 2 DONE
@dharsan.s7937
@dharsan.s7937 2 жыл бұрын
Solved all the practice problems
@AshishKumar-cw9xw
@AshishKumar-cw9xw Жыл бұрын
Can you please send the last problem solution
@Dr.dhumketuIITDholakpur
@Dr.dhumketuIITDholakpur 7 ай бұрын
can you please send link of last question that X time and K problem one
@priyojitghosh3672
@priyojitghosh3672 Жыл бұрын
not able to open the question link
@vivekgupta3484
@vivekgupta3484 Жыл бұрын
Make sure to signup on learning.algozenith.com
@abhi_3158
@abhi_3158 2 жыл бұрын
bhaiya can u decrease the font of the code so that we can see the all the code of one function in one time so that we can get the intution of the function more easily.Overall your content is amazing.
@ZSTAR_CODE
@ZSTAR_CODE 18 күн бұрын
NQueen backtracking 20:00
@hello-sb7zj
@hello-sb7zj 2 жыл бұрын
Can anyone tell what is the time complexity of example 3
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Let's discuss time complexity in today's Live class.
@hello-sb7zj
@hello-sb7zj 2 жыл бұрын
@@vivekgupta3484 ok sir
@PrasadTGS
@PrasadTGS Жыл бұрын
Is it possible to watch the live class now @@vivekgupta3484
@codemode2925
@codemode2925 2 жыл бұрын
need some more calrity on the reverting the choices part.
@abc-ym4zs
@abc-ym4zs Жыл бұрын
bhaiya i dont why i am afraid of doing new things how to comeout of this way
@PrasadTGS
@PrasadTGS Жыл бұрын
why did we take queens array size as 20 , dont it effect in case of large board
@SRoy2700
@SRoy2700 2 ай бұрын
yes if the board size is > 20 *20 then it would definitely
@jayantgupta5310
@jayantgupta5310 Жыл бұрын
Problems page is showing error 404 not found
@vivekgupta3484
@vivekgupta3484 10 ай бұрын
sorted now
@niveditashukla2901
@niveditashukla2901 2 жыл бұрын
bhaiya, I solved this count number of ways to climb stairs on an online coding platform but it showed TLE for some test cases!
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Great … check comments … not everything is DP ;P
@akshatsinghtomar9207
@akshatsinghtomar9207 Жыл бұрын
Isn't 3rd question a greedy problem?
@nitinchoudhary5183
@nitinchoudhary5183 2 жыл бұрын
could you please help to model “find all substrings of a input string” in level , choice , check , move framework
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Do you mean distinct substring? that is a from 2 problem ... we will discuss it don't worry.
@sababmuhammad4842
@sababmuhammad4842 Жыл бұрын
understood
@nikhilkumarv2577
@nikhilkumarv2577 2 жыл бұрын
🛐
@yashmohta6420
@yashmohta6420 Жыл бұрын
Bhaiya problem link is not working ,please do something about it.
@vivekgupta3484
@vivekgupta3484 10 ай бұрын
sorted now
@Sandeep-zd6dq
@Sandeep-zd6dq 2 жыл бұрын
In skill problem can we avoid that check if we keep timeTaken and itemTaken in our recursion states ??? Although not sure🤔 But this check enforce us to follow this structure 🙌
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Correct.. that's what we are actually gonna do ! Great observation.
@rachakondaeshwar4129
@rachakondaeshwar4129 6 ай бұрын
N queen is now easy
@aryanbarnwal5645
@aryanbarnwal5645 Жыл бұрын
problem link not working
@vivekgupta3484
@vivekgupta3484 10 ай бұрын
new course added
@shivankkunwar9669
@shivankkunwar9669 2 жыл бұрын
the videos are great but the algozenith platform is impossible to write code in java worst experience .
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
you are supposed to write in your own pc .. test and paste
@shivankkunwar9669
@shivankkunwar9669 2 жыл бұрын
@@vivekgupta3484 💁💁💁💁
@AmanChauhan-hr1wh
@AmanChauhan-hr1wh 2 жыл бұрын
ans=0 then ans+=...is confusing can anyone explain that part plss
@hritikrawat6452
@hritikrawat6452 2 жыл бұрын
May I know how we can verify 92 moves answer is correct or not?
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Because i got the same :D
@enigmanarratives1
@enigmanarratives1 2 жыл бұрын
how much tym will it take when i will be able to solve leetcode medium fast and without liiking solution i am 90 at leetcode
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
300 - 400 problems
@ashokcherry8015
@ashokcherry8015 2 жыл бұрын
I am from banglore
@ashokcherry8015
@ashokcherry8015 2 жыл бұрын
Bhaiyya meet up
@vivekgupta3484
@vivekgupta3484 2 жыл бұрын
Neend hi muskil se ho rhi hai kabhi kabhi... thoda aur ruk jao... par pakka karenge.
@jivanninawe3190
@jivanninawe3190 2 жыл бұрын
Bhai hindhi may banaho video
@DPCODE72
@DPCODE72 2 жыл бұрын
Heyyyy bro....small advice go with Hindi language!!
The Lost World: Living Room Edition
0:46
Daniel LaBelle
Рет қаралды 27 МЛН
Vampire SUCKS Human Energy 🧛🏻‍♂️🪫 (ft. @StevenHe )
0:34
Alan Chikin Chow
Рет қаралды 138 МЛН
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 906 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 859 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 677 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 234 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,3 МЛН
The Lost World: Living Room Edition
0:46
Daniel LaBelle
Рет қаралды 27 МЛН