A general way to solve algorithm problems

  Рет қаралды 192,894

Gaurav Sen

Gaurav Sen

Күн бұрын

This video is about using a methodical approach to solving analytical problems. Here are the steps:
1) Problem Definition
2) Representation of Constraints/Objects
3) Strategy/Approach to solving
4) Algorithm
5) Experimentation
MIT Lecture:
• 14. Learning: Sparse S...
Blog Post:
blog.hackerearth.com/how-solve-nondeterministic-polynomial-challenge-problems-programming-contests

Пікірлер: 150
@diljitpr1764
@diljitpr1764 5 жыл бұрын
Problem solving is more like backtracking. You start with some notion and then try to validate deep further where the deepest idea which has met all the constraints and requirements by definition is the correct answer. Most computer problems/programming challenges/interview challenges are always tricky, hence the thinking has to be fast which comes with practice. But starting off by writing sample testcases/possible inputs to the problem and reverse engineering the problem could also help in some cases if the solution fails to meet a certain criteria. As far with computer programming challenges are concerned, its all about pattern mapping to problems which we have already solved before(thats how brain works) and then try to figure out a solution from that.
@webartisan5500
@webartisan5500 6 жыл бұрын
I didn't get it that you were talking about prime numbers. I should go to sleep now :( good content. Subscribed.
@gkcs
@gkcs 6 жыл бұрын
Hahaha 😁
@yuktikhantwal2342
@yuktikhantwal2342 4 жыл бұрын
lol 😂
@tusharsinha9023
@tusharsinha9023 4 жыл бұрын
🤣🤣🤣🤣🤣🤣
@rutwickgangurde3247
@rutwickgangurde3247 3 жыл бұрын
Me too
@kunns123
@kunns123 4 жыл бұрын
Gaurav, I love the way you communicate and are able to formulate your thought-process into words. In my opinion, that is the ability which makes you stand out from others. Yes, being good at competitive and System design is one thing, but you are a natural teacher.
@neutron417
@neutron417 11 ай бұрын
Yeah he articulates very well
@ksansudeen
@ksansudeen 4 жыл бұрын
Thanks Gaurav.. finally i have started reading the text on questions and practicing to represent input formats..
@francishalloun7531
@francishalloun7531 4 жыл бұрын
An algorithm to solve algorithms
@gkcs
@gkcs 4 жыл бұрын
So meta 😛
@SatyamGupta-gc9sq
@SatyamGupta-gc9sq 4 жыл бұрын
Inception
@NevilleIsGod
@NevilleIsGod 4 жыл бұрын
Sometimes the algorithm we choose defines the representation. But this is a good map to consider
@mowahidlatif5006
@mowahidlatif5006 3 жыл бұрын
Love the enthusiasm my man! Also, great explanation! Subscribed and liked!
@gkcs
@gkcs 3 жыл бұрын
Much appreciated!
@sagarsureshsrikant785
@sagarsureshsrikant785 2 жыл бұрын
Hi Gaurav, You have given a wonderful roadmap to develop problem solving strategy. This reminds me of the first principles approach to deconstruct the problem into smaller pieces and then work methodically. Once again thanks a lot.
@andybarajas2696
@andybarajas2696 4 жыл бұрын
Interview tomorrow and am super nervous! this was very helpful btw
@coolDG1
@coolDG1 7 жыл бұрын
aaaaahh, whenever i am just getting started with something, you come up with a video related to it! Amazing!. I am totally for this method of problem solving. Recently, i have been stuck on some problems by simply either writing code straight away or making changes to it and what not. I try by changing "
@gkcs
@gkcs 7 жыл бұрын
Thanks Divyansh! Long, and informative comment :-)
@shyamkachhadiya4964
@shyamkachhadiya4964 5 жыл бұрын
Xd,, same
@cesareborgia9259
@cesareborgia9259 4 жыл бұрын
This is a good observation. I do this all the time, and it feels like a huge waste of my time.
@edumantralive7180
@edumantralive7180 5 жыл бұрын
Learning a lot from your channel. I am a failed programmer, hope one day I will get a good job because of you. Thanks for the wonderful video.
@ruslanuchan8880
@ruslanuchan8880 5 жыл бұрын
Good luck for you, bro :)
@denniszenanywhere
@denniszenanywhere 4 жыл бұрын
Man, I am a failed programmer, too. I cannot solve any problem.
@xordux7
@xordux7 4 жыл бұрын
Hey, it has been a year since you wrote this comment. Any good news yet?
@florinturcanu7109
@florinturcanu7109 4 жыл бұрын
I'm interested too
@amansinghbhadauria2818
@amansinghbhadauria2818 3 жыл бұрын
@@xordux7 How could I get notifications for this thread?
@vulturebeast
@vulturebeast 5 жыл бұрын
Have you applied this approach anywhere ? And what are your results regarding the same? PS: I will experiment with the exact framework for a week or so, thanks Gaurav for this :)
@kaizen6163
@kaizen6163 2 жыл бұрын
We need more videos like this!
@labuewilfred2259
@labuewilfred2259 3 жыл бұрын
This a very good approach , thanks
@RaviShankar-ok1kh
@RaviShankar-ok1kh 6 жыл бұрын
You have a 1000-card deck with cards numbered from 0 to 999 that you'd like to sort. You have a small table to sort the cards on, which can hold up to 64 piles of cards. You can't stick cards in the middle of a pile, but you can split a pile into additional piles (as long as you don't go over the limit). Can you describe out a good way to sort the entire deck of cards?
@AnonymousProdigy
@AnonymousProdigy 2 жыл бұрын
Super useful brother...thanks a ton ❤️..much love
@ashishrana6815
@ashishrana6815 7 жыл бұрын
GKCS, you are amazing, Thanks for awesome videos
@gkcs
@gkcs 7 жыл бұрын
Thanks Ashish!
@nechomagz309
@nechomagz309 2 жыл бұрын
Helped me alot thank you, I can see that you are going to be a teacher in the future
@yashchoudhary4791
@yashchoudhary4791 4 жыл бұрын
VERY NICE APPROACH IT REALLY HELPED ME😊
@TheErichX
@TheErichX 3 жыл бұрын
Awesome Bro! Pretty objective, thanks for share, cheers from Brazil o/
@MrGlujaN
@MrGlujaN 6 жыл бұрын
Thank you Gurav!, Your general approach to Problem solving, make me more confident in solving problems. I use it in college to pass finals and really works!
@gkcs
@gkcs 6 жыл бұрын
Awesome work Sebastian, congrats!
@nishantkumarbundela8482
@nishantkumarbundela8482 4 жыл бұрын
3:42 Minimized the video and googled "what the hell is a link-cut tree ?".
@harshitachaurasia1246
@harshitachaurasia1246 3 жыл бұрын
lol
@kennethcarvalho3684
@kennethcarvalho3684 4 жыл бұрын
Maybe we can look at Approach and Strategy as different points...I could say I have multiple approaches, for each approach I have multiple strategies..what is your view on this?? Finally you mentioned that this works in long term contests and not in short term contests.. I assume you mean there is no time to go through the entire waterfall and just dive into some of these areas and attempt to get a solution. But is there a specific approach for quick solutions.
@gkcs
@gkcs 4 жыл бұрын
You make a good point. One must adapt their methods according to circumstances.
@solomonhopewellkembo
@solomonhopewellkembo 2 жыл бұрын
This is really beautiful.
@sanchitsomani5
@sanchitsomani5 5 жыл бұрын
2. Representation. Have you elaborated it anywhere on your another video perhaps?
@gkcs
@gkcs 5 жыл бұрын
All the AI videos needed it. When dealing with a complex problem, representation is a key part of problem solving. My recent system design videos are very focused on the representation aspect.
@alexanderhermes6408
@alexanderhermes6408 4 жыл бұрын
Thanks!
@phanindrakumar5112
@phanindrakumar5112 3 жыл бұрын
Nice thought process :)
@nishantsingh1453
@nishantsingh1453 6 жыл бұрын
I am an aspiring coder and twice I have cracked Google code jam round 1. Two days back on 9th Feb ,i went to an interview in a product based company. I was asked to write a code on fibonacci series. Believe me , I started thinking of the for loops and damn I wsnt able to code it :( . I was just thinking of a reason and I guess ur video pretty much answers it. It's not how much u can code.but with what approach u get the solution . Thankful to u . Will be exploring the links in the description . And would be thankful if u can comment some examples where u have used the above approach or maybe post a video
@prajwalkale2687
@prajwalkale2687 5 жыл бұрын
Can you tell me plz From where you learned competitive programming
@KaziAmitHasan
@KaziAmitHasan 5 жыл бұрын
Great video
@ridwanmugdha7623
@ridwanmugdha7623 3 жыл бұрын
Man I love You. awesome Bro
@praveennaikg8171
@praveennaikg8171 4 жыл бұрын
Observation on sample examples works for most of the time.....observing the pattern in it is main thing...
@anmolmishra990
@anmolmishra990 7 жыл бұрын
I wish I could like this video more than once :)
@ranjitkumargouda8970
@ranjitkumargouda8970 6 жыл бұрын
Anmol Mishra Yes offcourse you can like the video twice...😂
@vivekchadha4109
@vivekchadha4109 7 жыл бұрын
sir please provide detail explanation of basic graph problems with stl implementation
@andreicompany954
@andreicompany954 6 жыл бұрын
Amazing!
@gkcs
@gkcs 6 жыл бұрын
Thanks Andrei!
@hanseldsilva2393
@hanseldsilva2393 4 жыл бұрын
How do you expect us to get what any of this means if you don't demonstrate with an example?
@khadeejamastoor4992
@khadeejamastoor4992 3 жыл бұрын
systematic way to solve the problems.Liked it
@ishumishra8104
@ishumishra8104 4 жыл бұрын
Hello Gaurav, I always dream of becoming good engineer who knows everything like time complexity, space complexity etc but when I try to read or solve Data structure it seems to be very boring to me, I am having 2year exp in JavaScript (Angular) etc
@ShauryaVlogsUppal
@ShauryaVlogsUppal 7 жыл бұрын
Please make a video on stl maps, set
@matthewslaton1366
@matthewslaton1366 2 жыл бұрын
good lesson, and thanks. it’s basically a feedback loop
@juanefrainpaquiyauri6590
@juanefrainpaquiyauri6590 4 жыл бұрын
This is very helpful for me
@NewsNachrichtenGermany
@NewsNachrichtenGermany 4 жыл бұрын
Thanks Gaurav.
@Purnviram03
@Purnviram03 4 жыл бұрын
I wish we were in same college and we did interesting things like this🙆‍♂️😂...I mean there is so much to learn from you and it's such a fun.... I would also appreciate if you can make a video on...How are you learning all this😂..so resourceful.
@gkcs
@gkcs 4 жыл бұрын
Hahaha, maybe someday 😁
@kushaldey9428
@kushaldey9428 7 жыл бұрын
can you plz upload the videoes on codechef snackdown elimination round contest held on 3rd june...
@ranam950
@ranam950 7 жыл бұрын
Please make some videos on DP , btw love ur channel
@gkcs
@gkcs 7 жыл бұрын
Coming up next! Thanks for the feedback :-)
@ankushmenat
@ankushmenat 4 жыл бұрын
How to Solve it by G. Polya has an approach for math, applies to pretty much any computational problem too.
@wettmarley
@wettmarley 4 жыл бұрын
u earned a sub today
@vaibhavisondur2577
@vaibhavisondur2577 4 жыл бұрын
Good one, Gaurav Sir... I endorse this method greatly as I have practically applied it and I've been successful. Regards.
@gkcs
@gkcs 4 жыл бұрын
Glad to hear that 😁
@dhanushk.s.5632
@dhanushk.s.5632 3 жыл бұрын
Hi Gaurav i recently came to know about your channel and im glad i found it. I need a few suggestions before i start solving problems in coding platforms such as Hackerrank, codeforces etc pls share you experience in learning data structures and algorithms ,im lacking the skill to apply the right algorithm for a given problem How do I overcome this??
@gkcs
@gkcs 3 жыл бұрын
I find Codeforces the best amongst them.
@dhanushk.s.5632
@dhanushk.s.5632 3 жыл бұрын
@@gkcs Thank you
@youarecorrectiamwrongbecau1338
@youarecorrectiamwrongbecau1338 4 жыл бұрын
Please give me some advice. I really need it. I did a codechef long challenge and solved 5 out of 8 problems in many days and many hours. Then I came to codeforces and saw the last div 2 contest problems.. I can't even solve the A, B and C problems there. I saw the tutorials but still can't understand the explanation after trying to understand it for hours. I am really disappointed and I know I have to do it anyhow as this summer I need to get into a good company. Please tell me what should I do in such a situation.
@inioluwa3413
@inioluwa3413 4 жыл бұрын
Are prime numbers the same as odd numbers.. I'm talking about the example you gave 1
@rahulshetty3738
@rahulshetty3738 7 жыл бұрын
if possible,please make a video on June long challenge PRMQ problem.
@gkcs
@gkcs 7 жыл бұрын
Hi Rahul! I am considering it...might skip it though, because it uses data structures we have previously talked about.
@Avatar911
@Avatar911 5 жыл бұрын
Could you please tell the best book to learn Data structures and algorithms...
@gkcs
@gkcs 5 жыл бұрын
Google it.
@meenushukla4321
@meenushukla4321 4 жыл бұрын
A very very good video I can understand full video
@gkcs
@gkcs 4 жыл бұрын
Glad to hear that!
@ankushvirmani9039
@ankushvirmani9039 7 жыл бұрын
U wont tell dp and its thought process , right??
@gkcs
@gkcs 7 жыл бұрын
I am going to mentioning this comment in the next video. :-P Wait for my answer there!
@AsifSaifuddinAuvipy
@AsifSaifuddinAuvipy 4 жыл бұрын
it's good for job interview ;)
@SAM-ro1vv
@SAM-ro1vv 6 жыл бұрын
Which language should I implement algorithms I k now c , python, java
@gkcs
@gkcs 6 жыл бұрын
+Incredible India You should try Malbolge, it does make life simpler. :-p On a serious note, any of the above are good enough to start with.
@KunalSwami
@KunalSwami 5 жыл бұрын
@@gkcs Hmm, in my opinion Brainfuck (en.wikipedia.org/wiki/Brainfuck) is better at making life simpler :P EDIT: Just read that Malbolge is built on the difficulty of Brainfuck and Befunge.
@gkcs
@gkcs 5 жыл бұрын
@@KunalSwami Hahaha, exactly!
@AhamedKabeer-wn1jb
@AhamedKabeer-wn1jb 4 жыл бұрын
Good...
@blocksofcode7631
@blocksofcode7631 5 жыл бұрын
What is mean of gkcs
@jaydabhi364
@jaydabhi364 Жыл бұрын
I think I am very dumb to solve computer science problem.. Can I still solve the problem with this approach?
@stunningstrokes
@stunningstrokes 2 жыл бұрын
What the hell? I was searching about youtube algorithm and I clicked on it expecting something like that but its a maths problem 🤣🤣🤣At first I got confused but now I understood 🤦🏻‍♀️
@shivamraj2649
@shivamraj2649 6 жыл бұрын
Bro you are doing really good thanks yaar Or tmhara playlists sab v series mai ha I am getting started with learning programming so any tips and way to learn and path I think i should go through you playlists one by one from top to bottom by learning and applying it
@gkcs
@gkcs 6 жыл бұрын
That's the way :)
@rahulbhatia1313
@rahulbhatia1313 6 жыл бұрын
1:39
@vaishnaviyashwantkadam20
@vaishnaviyashwantkadam20 3 жыл бұрын
Can u please explain this by taking one problem and then apply these pointers so that it could be more clear what each pointer practically means.
@bedodoru
@bedodoru 3 жыл бұрын
hello, I'm a student at university and I've got a question... Does it normal not to be able to solve the algorithm problems?
@sidhantmishra2734
@sidhantmishra2734 7 жыл бұрын
please provide tutorial on when and which data structure to implement depending up on the situation.
@reyaanuppal5007
@reyaanuppal5007 7 жыл бұрын
Sidhant Mishra It is easy to find which data structure to use while looking at the problem, the main catch is to code it and make it accepted.
@coolDG1
@coolDG1 7 жыл бұрын
Solving problems in competitive programming is mainly breaking down the unknown problem to a set of known problems. So the more problems you know the better your chances of success are. Just keep reading editorials, tutorials, new algorithms , data structure and keep solving problems. Knowing what data structure to implement will come to you only by practice. Although looking at constraints give you a pretty good idea.
@martjao
@martjao 7 жыл бұрын
Can you make a video of Wavelet Trees ? :D
@gkcs
@gkcs 7 жыл бұрын
Reading up on it. Seems very interesting...
@martjao
@martjao 7 жыл бұрын
Coool :D
@xordux7
@xordux7 4 жыл бұрын
He made the video.. kzbin.info/www/bejne/earFcpqMe5KAg8U .... Gaurav is awesome!
@fahmiirfan6923
@fahmiirfan6923 6 жыл бұрын
Sometimes we already know the definiton, represenstation, & the approach phase, so we jump to the algorithm phase.
@nicholaitukanov1162
@nicholaitukanov1162 5 жыл бұрын
You but not everyone
@ayushgames3764
@ayushgames3764 5 жыл бұрын
What is gkcs
@tkbhateja2071
@tkbhateja2071 3 жыл бұрын
I think first 3 steps are always done in our mind :p :p
@Chandyshot
@Chandyshot 7 жыл бұрын
problems where given an array and we need to find something based on gcd of all possible subarrays or subsequences, I can't make efficient way to solve these problems, can you help me with some of the named techniques.... any video or any comment regarding gcd topics will be helpful..
@gkcs
@gkcs 7 жыл бұрын
Most such GCD problems require us to do some precomputation or answer in ranges. You could try the problem: www.codechef.com/problems/GCDQ I will be making something on GCD soon. :-)
@Chandyshot
@Chandyshot 7 жыл бұрын
somewhat similar to XOR problems??
@gkcs
@gkcs 7 жыл бұрын
Yes, ranges tend to do that. But sometimes you need to work out a bit of math to simplify the query for the subarray
@bismeetsingh352
@bismeetsingh352 5 жыл бұрын
But how do u think of the algorithm in the first place
@gkcs
@gkcs 5 жыл бұрын
That's the part of problem solving. You define and then represent. The algorithm is a set of steps you choose to solve the problem.
@bismeetsingh352
@bismeetsingh352 5 жыл бұрын
@@gkcs That's where I get stuck. Finding those steps
@joonmoon7535
@joonmoon7535 4 жыл бұрын
Do u live out of india
@MegaAkash123456
@MegaAkash123456 7 жыл бұрын
yep! this approach wouldn't be that helpful in short contests, where you see the first solution on the table in minutes. It would be very helpful if you make a video on optimising dp problems after finding the recursive solution. Things like eliminating parameters and changing the state of the problem.
@coolDG1
@coolDG1 7 жыл бұрын
You still go through this procedure, just in your head :). And since problems in short contests are relatively easier to crack we think i just coded the solution right away!
@parthudawant7015
@parthudawant7015 3 жыл бұрын
Maybe having a methodical approach remove the funride we go through while programming. Don't you think so?
@gkcs
@gkcs 3 жыл бұрын
Solving problems will always remain an art, regardless of the science behind it. A method gives the art some structure. It doesn't take away from the beauty of it though.
@idrispatel7139
@idrispatel7139 5 жыл бұрын
I see mostly top ranking coder solve problem in c++ in code jam. Why they are prefer c++ other than?
@gkcs
@gkcs 5 жыл бұрын
It's faster than most other languages, so most competitive programmers choose that language. It's also shorter to write than languages like Java. However, there are some top competitive programmers who use Java too, like uwi.
@arjunkhanna1803
@arjunkhanna1803 3 жыл бұрын
Improve the audio quality please
@movieflix5155
@movieflix5155 5 жыл бұрын
please give me a way or some instructions from where and how could i start coding? and one more question in which language? i really want to start competitive programming. i studing cse in public university in bangladesh. thank you :) .
@umessr8456
@umessr8456 5 жыл бұрын
Start with Python 3 bez its easy
@eequalsmc2829
@eequalsmc2829 5 жыл бұрын
Is this from art of problem solving?
@gkcs
@gkcs 5 жыл бұрын
It's actually from an MIT professor of AI. You can have a look at the video description.
@eequalsmc2829
@eequalsmc2829 3 жыл бұрын
@@gkcs Thanks
@BHARATKOTESWARAO
@BHARATKOTESWARAO 6 жыл бұрын
"in our language means" haha yes we are another world lol
@leftover3857
@leftover3857 11 ай бұрын
I actually think like how my brain will solve this problem, I my brain can't do it, I certainly can't write any algorithm for it.
@naveenslog
@naveenslog 5 жыл бұрын
I have the t-shirt :)
@ritikpanday9617
@ritikpanday9617 4 жыл бұрын
by default I think like that
@ShauryaVlogsUppal
@ShauryaVlogsUppal 7 жыл бұрын
Also make a video on query questions, how to solve a query question
@gkcs
@gkcs 7 жыл бұрын
If you are talking about Range Minimum Queries, you could have a look at Segment Trees or Sqrt Decomposition. Segment Tree: kzbin.info/www/bejne/eX-Tf2Sama9snqM Sqrt Decomposition: kzbin.info/www/bejne/nYjFdaKZjs2qeqM
@laminlevrai1758
@laminlevrai1758 4 жыл бұрын
I want to master arrays (type od a data structure) manipulation, I'm learning c++, for example how to write an algorithm to rearrange the elements of an array so that the zeros come first than the negative elements next than the positive elements last. Can you make videos about this?
@luckysahu6756
@luckysahu6756 6 жыл бұрын
what an expression at 3:04
@sociajl751
@sociajl751 3 жыл бұрын
why am I just finding this.....
@userd-yo1hf
@userd-yo1hf Жыл бұрын
what i do. works always get problem -> break it to small -> solve one fucking thing at a time -> combine all -> problem solved.. \
@shyamkachhadiya4964
@shyamkachhadiya4964 5 жыл бұрын
AH i have just jumped in compititive programaming a week before, and for mem programming looks wild, XD, every ties all logic needs to get worked , RIp me
@vishakha7493
@vishakha7493 4 жыл бұрын
This guy is ceo of whiteboard
@antarsarkar1058
@antarsarkar1058 5 жыл бұрын
why don't you show it head on rather than describing....
@gkcs
@gkcs 5 жыл бұрын
There's videos on editorials on this channel. Try them out 🙂
@alperkalamanoglu4660
@alperkalamanoglu4660 3 жыл бұрын
Me: That's the girl I was talking about, but don't look. My friends: 1:39
@gkcs
@gkcs 3 жыл бұрын
😂😂
Understanding Dynamic Programming
7:28
Gaurav Sen
Рет қаралды 100 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 534 М.
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 26 МЛН
UFC Vegas 93 : Алмабаев VS Джонсон
02:01
Setanta Sports UFC
Рет қаралды 217 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 28 МЛН
Whiteboard Coding Interviews: 6 Steps to Solve Any Problem
15:18
Fullstack Academy
Рет қаралды 359 М.
Intro to Competitive Programming
11:41
Junferno
Рет қаралды 762 М.
Advice from the Top 1% of Software Engineers
10:21
Kevin Naughton Jr.
Рет қаралды 3,2 МЛН
Problem-Solving for Developers - A Beginner's Guide
10:44
Fireship
Рет қаралды 736 М.
Algorithms Explained for Beginners - How I Wish I Was Taught
17:38
Internet Made Coder
Рет қаралды 326 М.
Why coding interviews are broken
7:20
Gaurav Sen
Рет қаралды 14 М.
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 60 М.
The KEY To Thinking Like a Programmer (Fix This Or Keep Struggling)
10:39