The Harsh Truth about DSA in 2023.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so data fractures and algorithms a video I was dreading to make for a while but finally the time is here in this video we'll be discussing whether or not data structures and algorithms are still relevant in 2023. there's a lot of debate around this whether you should be doing development or whether you should go all in on TSA and in this video I will share my experiences and what I think is currently happening and needed in the market there will be points where I might speak against the culture of DSA and whenever that happens I will be solving a data structures and algorithms problem just so you know that I am still connected to my roots and even though I am saying at some points that DSA might not be the best thing to pursue I still understand it and do it once in a while and hence whatever I say in this video take it with a pinch of salt depending on where you are in your career right now I'm saying this after four years of working in the industry so some things that might not be relevant for me might be relevant for you so with all of that context let's get right into the video to begin with we need to under understand why there's an obsession around data structures and algorithms I'll tell you why it was a big thing back in my campus IIT roorkee back in 2014 when I started my computer science Journey at iitr a lot of discussions amongst the computer science folks were around this guy going to Facebook in the US or this guy joining Google's office in Mountain View California and every time it was very obvious that the person who made it which were usually like two to three people in a year were very good at the data structures and algorithms for some reason these companies really wanted Engineers who had their ideas sorted and every year it was like a pattern that the best data structures and algorithmic coders of the campus would either go to Google or meta in the US this was one of the biggest if not the only reason that a lot of people were intrigued by this thing called Data succession algorithms and this funnel kept on growing bigger and bigger even companies in India sometimes Amazon and other non-tech companies would hire Based on data structures and algorithms and hence it was very evident to everyone that if you want an on-campus placement the best thing you you can do is learn data structures and algorithms and I think that is the culture that flew throughout the industry among students and is still relevant today the best way to get a job as a fresher especially in a big tech company is through data structures and algorithms period the three reasons why these big tech companies use this as a metric is one it becomes easy to filter out the crowd there are a lot of engineering graduates in India and hence this becomes a basic Benchmark that everyone needs to crack through two data structures and algorithms strengthen some of your Basics and fundamentals of computer science you're able to solve puzzles and usually are proficient in some language and are able to write code if you can solve an algorithmic problem that comes in these contests and three there is diversity in languages but DSA unites them God knows what team or Tech stack you'll be working in once you join a big tech company hence they filter out candidates Based on data success and algorithms and eventually the thinking is this person who is good at solving data structures and algorithms might also be able to understand how the complex systems of this big tech company works so in a nutshell tell the biggest reason for this hype around data structures and algorithms is that it is used as a filtering mechanism by a lot of companies and I've personally been guilty of this as well a lot of my time during the campus was spent on solving these problems just so I could get the best on-campus job but looking back now I think I could have spent that time doing something much better and maybe could have landed a similar or a better job if I focused my energies on something else which is purely developing my skills so this is the first point where I've spoken slightly against data structures and algorithms so let's solve our first problem the goal of this video is also to make people start DSA if they haven't already just to give a beginner friendly tutorial I am solving this problem on lead code if you don't know what lead code is it's a platform where you can go sign up look at problems in their problems list if you go right here and I've chosen a few easy problems to solve just so you can get started if you haven't already the first problem we're solving is called is palindrome very easy problem what is a palindrome this is a computer science jharkhand usually I did not hear this before I solved this problem in college uh string that looks similar when reversed is called a palindrome for example Naman the very common name is a palindrome or if we purely talk in terms of numbers one two three three to one is a palindrome even one two three two one is a palindrome because if you reverse it it looks the same and when you're solving these data structures and algorithms problems what you have to do is you'll be given an input in a function you have to basically try to solve whatever the puzzle they want you to solve and then return some value in it in this specific problem as you can see they're telling you if the input to a function is the number that you have to tell whether or not it is a palindrome and the output needs to be a Boolean which is either true or false based on whether or not it is a balanced term the way to solve it assuming you know the syntax of some language is specifically this problem is this is a number and there's a better way to solve this this is like the easiest approach that uses some extra space is to create an array let's call it R and start pushing some values and just convert this number into an array of single digits how we do that is something slightly mathematical the way to do that is while X is not equal to 0 and I'll just explain this in a second add dot push x modulo 10 x equal to x divided by 10. so if you look at this logic what it's basically doing is if the input is one two three first it will extract the last digit x modulo 10 or 1 to 3 modulo 10 is 3 modulo is basically the remainder if you divide this number by 10 and hence the array will look something like 3 at the first iteration and then we divide X by 10 one thing to note here is we're using JavaScript and hence we need to floor this value else what will happen is uh this will probably become one 12.3 which we don't want we want it to be an integer at all times hence we take the floor and because of some Precision issues in JavaScript we should also make it look something like this while X is greater than zero keep doing running these iterations the first time what the array will become three and the value of x will become 12 after the first iteration in the second iteration it will pull the last digit from 12 which is nothing but 2 hence the array will look something like this and the last iteration the array will pull out the last digit from the digit one which is one itself and helps you you have this array that looks something like this three to one by the end of this Loop and you've stored these values in this R variable once you have that all you have to do is compare the first digit in the last digit compare the second digit and the second last digit so on and so forth the easy way to do that is for let I equal to 0 I less than r dot length I plus plus if R of I is not equal to RF r dot length minus 1 minus I return false and if you never return false it means everything matched and hence you return true hopefully I'm right on this I am wrong because negative numbers can also be inputs and if you have a reverse a negative number it will not look the same because minus will go to the end of it hence you can just add a condition here if x is less than 0 then you can simply return true or false let me know in the comments I hope that does it I don't want this video to go too long there you go it works uh you can optimize this you can actually get rid of the array but I leave that as an exercise and what happened here is something you do again and again for a lot of problems if you want to get good at data structures and algorithms and if you really want to go one step ahead you can go to this platform called code forces that I used to solve contests in back in college so the thing about this platform is what he'll do is it'll basically have these problems but you'll it'll be in a Time bound manner within three hours and based on the number of problems you solve you'll get a rank and then those ranks translate to these ratings so if you give a lot of contest as you can see I gave a lot of contests before I sort of my my interest in data structures algorithms went away every contest based on your rank your rating goes up or down very similar to chess ratings so it's like a fun way to solve data structures and algorithm problems so if you want to go one step ahead do this else lead code is enough for interviews if big tech companies is what you're aiming for cool let's proceed with the video so as you saw a lot of data structures and algorithms is just trying to solve a problem and unluckily luckily what happens in the industry is a lot of focuses on building products and eventually the focus is on optimizing them by using these algorithms so unfortunately most companies use like a bottom up approach like this where they'll create an optimized version of some product and then eventually they'll optimize it and you can always look up Google and find algorithms to make your code better and better and hence I personally feel this is not used in the industry as much as people spend their times during colleges solving problems like these and I was given the same advice by a bunch of college seniors of mine who were really into startups and understood startups before there were a thing or before Shark Tank was a series I of course did not take them seriously and still focused on DSA and tracking the best on-campus placement in retrospect they were right startups today are the craze and today a lot of people understand that compared to a big Tech Fan Company a startup might be a very good career path both in terms of money and your learning curve and hence my advice to to you now would be two things you can focus on if you get over this craze of data structures and algorithms and I'll just solve another problem because this is the second time I'm crossing it is one choose some Niche big tech technology that not a lot of people work on and get really good at it a few industries that pop in my head are AI machine learning and web3 again this is counterintuitive advice but that's how you win I was given similar advice back in college and I did not take it I hope that you guys do and it'll be this small group of people that differentiate themselves from the herd they'll end up doing great in a few years so if that is you the path for you to take is do a lot of Open Source work Google summer of code is right around the corner pick an organization start contributing and start doing actual work that you will do once you join a company just before this video I spent some time looking at the code forces problems I used to solve and quite frankly they boggled my head and it's so surprising that none of the problems that I've solved I ever used in my career and I totally could have spent that time doing more open source luckily I figured this out around second and third year and started contributing to open source and ended up doing gsoc twice and if this video can change the opinion of even five percent of the people who are watching this video and some of you can get into G-Shock I think this video will be a big win for me with that I'll solve one more problem because this was the second time I spoke against DSA however if you want to know how to contribute to open source here's a video I made with my friend harnu Singh where we helped him make his first open source contribution and if you want more of these let me know in the comments with that let's get to the second problem that I chose which was called rotate strings so this problem again I'll try to tease it from the very Basics what it says is given two strings s and goal so your function has two inputs s and col return true only if s can become gold after some number of shifts on S so if you look at the example if the input is a b c d e and goal is c d e a b the answer is true because if you rotate ABCDE three times it becomes CD e a b there is an optimal way to solve it which I will leave for you you guys to solve but since the constraints here uh say that the value of both s and goal are between 1 and 100 we can actually solve this in order n square if you don't know what I'm talking about here Order n Square uh you should look at a few videos around time complexity and Link some in the description um so what I'm doing here is using a very bad way to solve this problem basically and you should find one what time complexity is and two what is the more optimal way of solving this problem so you're given string one you're given string two the dumbest way of solving this is you keep rotating string one you rotate it once you rotate it twice you keep doing that until you find the match luckily you only have to do it s dot length number of times if the length of the string is five you only have to rotate it five times and compare it with Goal because you know so if you rotated the sixth time it again is equivalent to you rotating it the first time if you rotate a b c d e once it becomes b c d a if you rotate it six times it Still Remains b c d e a hence rotating it more than n number of times where n is the length of the string doesn't really do you good so you only have to rotate it n number of times the way you do that is you create a for Loop let I equal to zero I less than as dot length I plus plus one small thing to type at the very top is if s dot length is not equal to goal dot length it will return what false because no matter how much you rotate the first string it can never be equal to the second string if their lengths are not the same now the first iteration or this variable I represents how many times you have to rotate the first array you still have to rotate it for which you have to create a second for Loop for let J equal to 0 J less than well s dot length doesn't matter because the length of both the things are are the same because we already put a check here at the top now this guy first has to rotate the first array and then compare it with the second array now to save some space what I'm going to write some logic here and then explain it logic is if um s of I plus J Mod Dot length it's not equal to S of I mod s dot length probably don't need this uh wrong answer which comes to tell you I am extremely rested and maybe even dumb missing something obvious here oh sorry probably won't fix it based on the test case we saw foreign foreign is naughty and bring some lazy debugging here what I've done is printed out inj let's uh zero zero let's just break here because once it becomes false it will remain false sorry I'm just talking to myself here I will explain this better once I'm able to solve it zero zero one zero two zero three zero three zero two zero so two s of 2 which is ABC is not equal to goal of I my bad the classic ing flip okay there we go so let me explain the solution and then maybe explain what I went wrong um over here as I told you inside this logic we need to rotate the first array once or twice or Thrice based on this I variable the way we do that is we don't actually create a new variable that has the rotated array even though you can do that what we're doing is we're comparing s of I plus J mod s dot length and it's very confusing if this is the first time you are seeing this um but what I'm doing here I we know is the number of times we need to rotate the first link and J is simply the counter that's rotating that's uh going through the length of the string because it needs to compare character by character rather than comparing s of 0 and J of 0 I can compare s of 0 plus the number of times I need to rotate the first array and the first letter of goal so rather than comparing s of 0 and goal of 0 I compare s of 2 and goal of 0 which is equivalent to US rotating s two times and I keep doing that for I from 0 to s dot length which basically means I completely rotate the first array as the problem statement I completely rotate the first array I go from I compare a b c d e with the second thing then I compare b c d e a with the second thing so on and so forth and at some point when the first string becomes c d e a b they match and hence I return true here if none of the matches happen false get returns at the very end hopefully this was clear if not I'll link a much better solution to this in the description and that's it the debate ends here if I was currently in college I would tell myself to spend as much time as I could on open source and actual development and maybe keep doing this on the side doesn't really matter it's like your college examinations it's like an evil that you have to do just to get that GPA so I wouldn't mind spending some time on this unless you're actually interested in solving algorithms don't do it just for the sake of getting a job there are much easier better ways of getting a job today with that let's end the video and I'll see you in the next one
Info
Channel: Harkirat Singh
Views: 191,471
Rating: undefined out of 5
Keywords:
Id: EPypOeMHq5U
Channel Id: undefined
Length: 17min 28sec (1048 seconds)
Published: Thu Jan 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.