r/learnprogramming • u/Urgokk • Oct 25 '20
I just failed my first coding interview and realized I need a deeper understanding of algorithms. Which resources would you recommend?
TLDR: Tittle + should I focus on basic algorithms resources or go straight for interview focused stuff?
Background: I'm a civil engineer transitioning to IT, I finished some intro courses + a web dev bootcamp-style course. My career plan right now involves looking for a junior position as a developer and eventually start a MS in computer science or software engineering, while also getting on the job experience.
On Friday I had my first programming assessment sent to me. I had 2.5hs to solve 2 problems using Python, one involving string manipulation and the other defining a class with several methods. The first one was super simple, but took me way too long. I couldn't finish the second one, in part because I wasn't very familiar with Python's class syntax and in part because I'm still not very comfortable with OOP. If I had an extra hour, I could have finished it, but it wasn't the case.
I'm very proud of getting as far as I did, but I realized I don't have a good grasp of algorithms fundamentals and that I'm definitely lacking practice in these time-constrained exercises.
In general I'm the kind of person that likes to learn fundamentals before application. So I ask you guys: Do you think I should focus on basic algorithms bibliography or should I go straight to stuff like "Cracking the Coding Interview"? In any case, what books/courses/etc. would you recommend for someone in my situation?
37
u/DaredewilSK Oct 25 '20
That actually sounds like you lack coding on your own. You went straight into the interview from the tutorials, didn't you?
29
u/Urgokk Oct 25 '20
You are partially right, I did some personal projects (mostly webpages using React and Node), but I didn't have any big logical/algorithmically complex problems while doing so. I definitely lack practice and knowledge in the subject, that's why I made this post :)
5
u/greebo42 Oct 25 '20
I've read most of the comments up to this point. I like your systematic and philosophical approach. In the process of reading several answers, TIL about the grokking algorithms book (thanks everyone!).
I bet you can think of a few projects that could solve some kind of problem. Maybe use Python for those projects, so you get practice (in 3.8 or whatever it is these days) with it, especially for setting up classes with state data and methods. I think working on projects of interest to you is the best way to get useful experience, because you're going down rabbit holes all the time and at the other end, you have something to show for it.
21
u/dacian88 Oct 25 '20 edited Oct 25 '20
Your problem isn’t algorithms, your problem is lack of experience with your tools, this is very common among people trying to get jobs as juniors in software. Compsci grads have 4 years of experience with various programming languages, used to develop a bunch of meaty projects over the course of their degree. I’ve seen nee grads with more in depth knowledge of certain things than people with years of experience. 4 years is a lot of time to learn.
If you really want a leg up here’s some things that always stand out for me:
know your chosen language well, there’s nothing worse than understanding a problem, having a workable design but completely failing to implement it.
have a few non trivial projects you can talk about on your resume or an interview. Some good ideas here are: some kind of a web app, something using a db, something involving networking, something like a programming language interpreter or compiler. A compsci grad from a semi decent school would have likely done all these projects. You can even combine some of them...ie write a LISP repl in JavaScript/html.
4
u/Urgokk Oct 25 '20
You know, your first point was definitely my case. As I mentioned in the OP, most of my programming experience is using JS in the context of the Web Dev bootcamp (and a couple personal projects I developed after that), I also included Python in my resume because I used it in prior courses, but I'm not as experienced with it. I had the solutions in my mind but was having a hard time implementing them.
8
u/JesterShepherd Oct 25 '20
The top post of this sub right now is this exact question.
3
u/Urgokk Oct 25 '20
Thanks, I just checked it and found some very useful answers. I also wanted to know about recommended books and not only interactive websites.
6
865
u/Falcao_E Oct 25 '20
https://github.com/jwasham/coding-interview-university
This the best resource I can offer. I'm getting ready for my interviews too
41
28
u/noooit Oct 25 '20
You are amazing, I'm terrible at dynamic programming especially when the time is limited. I hope I can improve myself with this.
Thanks a lot!13
u/sudNinja Oct 25 '20
Thx sir.
I am getting into the "course hell" all weeks i found new links like this very well organized with so many material into it. Is really very dificult for a newbie like me to be able to know into which resources focus because of the big amount of resources available.
→ More replies (1)6
4
u/ItsOkILoveYouMYbb Oct 25 '20
Wow no kidding. I'm gonna work my way through this for as long as it takes. Thanks for this.
3
4
2
2
2
2
2
2
→ More replies (3)2
33
u/michael0x2a Oct 25 '20
FAQ - How do I learn topics covered by a typical computer science degree? has some suggestions on resources for learning about specifically data structures and algorithms (among other topics).
33
u/gnatbeetle Oct 25 '20 edited Oct 25 '20
If you want to learn the bare minimum in the shortest amount of time, then read Cracking the Coding interview(CTCI).
If you want to learn the subject well, then watch university lectures and/or read a textbook as reference. There are plenty of lectures and textbooks available but my favorites are MIT 6.006/6.046 and CLRS.
Honestly, the resources you that you use to learn DS&A doesn't matter. Getting good at solving problems is a lot of practice and reading solutions/editorials. Most of my practical knowledge comes from reading articles on GeeksForGeeks(GFG) and competition sites (TopCoder, LeetCode, Codeforces).
57
Oct 25 '20
Take a data structures class, I didn't really understand the need for it until that class. It went over stacks, nodes and queues which were created for the limitations of the hardware of the time. They would create something that could expand over and over so the program could run itself. Overall it's a good thing to understand the need behind the creation of the structure. Necessity drove the creation of the stack as the memory was physically limited and could only handle so many processes at once. They figured out brilliant ways of solving problems that to me is very interesting.
→ More replies (4)7
u/Lycanthrosis Oct 25 '20
This does sound super interesting. I am in the middle of a discrete math class currently and we just finished going over analyzing time complexity of algorithms. Got very little background on it and practical application info, which I feel always helps me.
5
u/set22 Oct 25 '20
I’m currently in discrete 1. I feel so lost all of the time lol. Also taking data structures though and loving it
→ More replies (1)
64
u/_bran_bran Oct 25 '20
Best material on the interwebz. Continue applying and you got this! Cheers
→ More replies (1)6
u/analton Oct 25 '20
I just watched the first video on OOP list. Best explanation I've ever seen.
2
u/RoguePlanet1 Oct 26 '20
So much Python, I'm trying to get comfortable with JS before I start dabbling in Python.
→ More replies (2)
17
u/Codethelifeyouwant Oct 25 '20
Hey there! I also recently failed my first hackerrank take home! I had an hour to answer 7 questions 5 multiple choice and 2 coding questions. I realized that taking a class doesn’t really thrill the data structures or algorithms in my head. One of the Reddit user was nice enough to walk me to how to solve a coding problem. He suggested that I read “Grokking the algorithms” it’s have pictures and explained things well. I am still in the process of reading the book but highly recommend if you are a visual learner + would like to understand without confusing wording.
3
u/a_HerculePoirot_fan Oct 26 '20
Grokking the algorithms
thanks, I will give this book a try. I just started Python and am struggling because I don't have any knowledge in Algorithm and so I can't understand the way computer thinks. At the same time, I am a visual learner and I feel I can understand easier if I can SEE how algorithms work.
4
u/Codethelifeyouwant Oct 26 '20
CS50 was a really good class, if you want to know how algo works. It’s an intro to computer science. There is also quite a few Udemy classes that call data structures and algorithms in python
28
u/Periwinkle_Lost Oct 25 '20
I’m an electrical eng moving into development. Algorithms aren’t that bad, I don’t know if you had to take them at school (it’s a required course for electrical stream). My plan is to sit write down most common sorting, searching, and path finding algorithms complete with pseudo code and complexities.
10
u/TennBass93 Oct 25 '20
Random but can I ask why you are leaving electrical engineering?
30
u/Periwinkle_Lost Oct 25 '20
I can’t find a job. There are far fewer eng jobs than there are dev jobs. Transition doesn’t seem that bad because I already have some knowledge of computer hardware and low level programming. Web dev and databases is where I struggle the most. I can write desktop apps and I know how drivers are designed so I decided it’s worth a try.
My goal is learning python, django, sql, and AWS for setting up cloud infrastructure. Algorithms is something that hiring managers ask a lot, and it seems to be a necessary evil. As an engineer I don’t have a problem to systematically break down problems and getting a solution step-by-step. Algorithms are just a proof for managers that you know how to do it formally
7
u/beardfearer Oct 25 '20
Hey you might be able to transition even faster and get some pretty sweet gigs in systems/hardware engineering. You probably already know most of the theory involved.
Thinking of places like Square, Apple, Tesla, etc. where a large part of their business is hardware.
Edit: to add to this, your existing knowledge in electrical engineering would likely be a real nice resume boost for these types of roles.
7
u/Periwinkle_Lost Oct 25 '20
Hardware engineering is hard for me. Like really hard. Every lab and project were like torture. HDL (hardware description languages) aren’t as easy to wrap my head around like c or python. I will go there if I can’t find anything for pure software.
→ More replies (10)5
Oct 25 '20 edited Oct 25 '20
It's not just a necessary evil. It's the core fundamental of Computer Science. Say you learn X programming language, but in future the language might not be as popular you would have to learn another one. But fundamentals like Data Structures, Algorithms, Database concepts, Operating System concepts don't change. Whenever you are learning a new skill it's better to start with the fundamentals, the root level and build on top of them.
→ More replies (1)
7
7
u/LesTerribles Oct 25 '20
This article worked wonders for me in recursion and DP.
https://jeremyaguilon.me/blog/a_collection_of_whiteboard_interview_templates
5
u/T567U18 Oct 25 '20
we all fail my man, the only way we learn.
that website has help me a lot, discussions can go either way so is up to you if you want to get into that mess. and to get good at it there are not short cuts you'll just have to do it, just remember Rome wasn't made in a day, so take your time and don't get discourage most of us are in the same boat and some of us will fail till we not.
5
u/sharjeelsidd Oct 25 '20
An email sent to you every day about a CS topic and practice questions sent at the end of the week.
16
Oct 25 '20
Sounds like you just don't have enough practice writing code. Maybe you should get on one of these challenge websites and practice on those problems?
10
u/hem10ck Oct 25 '20
It’s the best way to learn and refine skills. Advent of Code has some fun challenges.
4
u/kishorenirv Oct 25 '20
This course is legit. Helped me a lot. And he explains each line perfectly. Try it out.
2
1
u/liaguris Oct 25 '20
Can you show us these two problems ?
3
u/Urgokk Oct 25 '20
I'm not entirely sure if it's ethical to share the actual exercises, but the first one involved writing a function that would reverse words in an array, so if your input was "Hello, how are you?" (plus a list of delimiters, like ['.', ',', ' ' ...]) it should output "olleH, woh era ouy".
The second one involved defining a class used to track phone calls and how much to charge for them. I had to implement several methods, mainly in two categories:
Register a call made by a certain user, there were several different types of calls, involving different costs, for example, charging extra during peak hours.
Show information about the registered calls, like the amount of calls made by a specific user or the total cost of every call made.
→ More replies (1)
3
u/samketa Oct 25 '20
Start with Grokking Algorithms. It would be a light read. Then read Cracking the Coding Interview. That should do it.
And you should be able to implement those algorithms in code. Ideally in C++, Java or Python.
If you want a more systematic approach, read Skiena's Algorithm Design Manual.
Leetcode everyday. You could start with Codewars.
4
2
u/Zomokocske Oct 25 '20
Although certainly worthwhile learning it doesn't really sound like 'algorithms' was the problem.
For basic logic puzzles you should try a site like codingbat. A few hours messing around with their string, array, logic questions etc and you'll get much better at solving those style of problems.
As for OOP, I don't really have any recommendations for python as I mainly learned it through java, c++ and then c#. But it shouldn't be too difficult. Look up a brief python class tutorial and try making a few simple classes, then try using the object methods etc.
Neither topic is too difficult, I'm sure you'll get it down with some practice.
2
2
u/Federico95ita Oct 25 '20
The way I became successful in coding interviews was taking a solid algo course on coursera and the grinding LeetCode once I was able to easily write any data structure from scratch
0
2
2
u/TriusMalarky Oct 25 '20
As a student, is it possible I can get a better idea of what the question/assignment was? I might not be able to help you, but a good idea of the assignment's details would help me out.
2
u/filtoid Oct 25 '20
I, personally, was in a similar situation very recently, although I've been a dev for a few years but largely self taught. I wish you luck and advise you not to get too down about them, they aren't very accurate imho and it can come down to how you feel on the day or if your initial instinct for the solution is proved right during the task
I would however recommend Grokking Algorithms, an excellent book on algorithms and data structures which explains the subject very well.
In terms of classes and OOP I would recommend finding a task you find interesting and create objects which represent those data items and investigate how a class could encapsulate the functionality of that object. Games are often a good way of doing this - Pygame is very accessible for getting started. Try creating a Player class and see how things go from there.
In my experience books only work so well for me, practical application cements that knowledge in there so writing an app that I find interesting is the best way to get started. YMMV of course.
2
u/Sidiabdulassar Oct 26 '20 edited Oct 26 '20
Games are often a good way of doing this - Pygame is very accessible for getting started
This!
I've been using Python for years, mainly for file manipulation and data analysis. I never felt the need of using classes/objects until I made a little game using Pygame. Try it out. It's not only fun but very educational!
2
2
2
u/amhotw Oct 26 '20
Roughgarden's algorithms book series + lectures is probably the most accessible resources on algorithms.
2
u/Dexiro Oct 26 '20
I've never felt the need to memorize algorithms, in any programming job, test or interview. It's weird to see someone focus on "learning algorithms" as a means to pass an interview.
1
u/Double_A_92 Oct 26 '20 edited Oct 26 '20
It's mostly a thing that shitty companies do, because they don't know what they need from their devs or because they have some complex HR system. Then shitty developpers eat it, because it's relatively easy to game that system by just memorizing stuff instead of actually understanding software engineering.
Practicing algorithms is useful because it teaches you how to quickly understand arbitrary logic things, but forcefully memorizing tons of algorithms is just stupid.
2
Oct 26 '20
Don’t forget all the great resources at freeCodeCamp.org, they’ve got videos, blog posts, and a specific section on learning to crush your interview
3
u/Random_182f2565 Oct 25 '20
That's always make me wonder, do companies want a mechanic or a pilot? Do they even know the difference?
0
Oct 25 '20
[deleted]
2
u/Random_182f2565 Oct 25 '20
That's part of the reason why I decided programing was a hobby and to focus my efforts in being an online tutor.
1
u/corleone089 Oct 25 '20
Personal advise/recommendation choose one object oriented language. Get a book which explores the language in absolute depth. While reading the book, practice coding in leetcode. Dedicate your life into doing leetcode. For time pass do a project of your choose as well
1
u/firestepper Oct 25 '20
Also... do timed challenges. Practice under the same conditions a coding test would be given
1
u/duhhobo Oct 25 '20
I would also keep interviewing until you find an interview that gives you a take home project
1
1
u/SsinzSidney Oct 25 '20
I'm gonna take my 1st OA without basic dsa too. I know I'm gonna flunk it but just want to give it a try and get better in them as much as possible later.
1
1
u/Kratos3301 Oct 25 '20
well its not ethical but if you have no problem with a bit of hindi or pirating stuffs then try to grab the "coding ninjas" and/or the "coding blocks" c++ and DSA course from telegram. They actually teach well and they just make it easier to understand medium/hard problems. No idea if this helps or not but just shared in case
1
u/xdchan Oct 25 '20
Well, you see, algorithms and data structures are cool, you may want to learn a bit about them, but they are already written and ready to use, so it's not crucial to learn them.
You failed cuz you wasn't prepared to work with classes and OOP, not because you need to learn algorithms.
1
u/thecolector Oct 25 '20
You're not the only one. I failed mine too a while ago. NEVER GIVE UP and keep learning&coding !! Wish you the best
1
u/Omkar_K45 Oct 25 '20
Do you guys recommend python for DSA ? Please suggest because I'm gonna be starting my DSA prep next week and it's hella confusing me choosing b/w cpp and python
1
u/poipo23 Oct 25 '20
I am having similar problem... Tho I am good (not best) with algo and data str. But idk why but I can't solve more than third of questions (approx) que in coding rounds of interview process. I read from books like CLRS, but no avail and am still failing in rounds. Idk what to do. Can someone suggest anything ?
1
u/Its_Daffy Oct 25 '20
Algoexpert.io was a site created for exactly this! They have questions from actual interviews that you can practice
1
u/mickey_s Oct 25 '20
geeksforgeeks.com has a really good course on algorithms
1
u/wishicouldcode Oct 26 '20
The paid one?
1
u/mickey_s Oct 26 '20
Oh, I’m not aware of a paid one. Just a lot of good content I guess. Not so much a course
1
1
u/BigoBigoHey Oct 25 '20
I covered some of the topics mentioned during my bachelor as a communication systems engineer. Later I got lost in communications systems when everything that interested me was over on the twin section at computer sciences. This was very interesting to learn and you should give it a go if you're into that stuff. Today I'm doing a programming bootcamp at school and some students there in 4th year haven't heard of algorithms complexity. You can be a dev without this. You can't be hired at google and amazon without it (if that's the plan). Now that I'm becoming a dev, I'll definitely open some books from my college time and study that again because I loved it and was really good at it when most of the class struggled a lot. Takes some times though. Good luck, whatever path you choose !
1
u/LuisaGeorgiana Oct 25 '20
Congrats for having the courage to transition and take your first interview!
First of all try to implement all the data structures and understand when and how to use them. They sit at the core of everything in programming. If you know them, you'll have a better understanding of frameworks, design pattern, optimization problems, algoritms. That's why you always see them grouped "Algoritms and Data Structures".
Secondly, most of the material is quite mathematic, so do lots of examples by hand with each data structures and try to visualize them.
Best of luck! :)
1
u/JKarlavige Oct 26 '20
It is okay to fail. It’s not only about what you know in the code, but also about how you fit in with the company. Denial is not always a loss, giving you more time to find the right position
1
Oct 26 '20
I suggest reading Cracking the Coding Interview. That has a lot of material on algorithm questions. These questions are dumb because programmers rarely use this knowledge in real life, especially web developers. Some companies don't even ask algorithm questions and instead ask questions about the languages they use or ask you to write code for them.
If the job was in Python, and the interview was in Python, then being weak in Python was obviously going to hurt you big time. There is no way to make up for not properly knowing the language the job required.
1
u/jsmit6 Oct 26 '20
In my opinion, learning interview questions masks the underlying issue. There are many schools of thought on the process, but here is mine: If you get a job without having a deep understanding of algorithms, that is perfectly fine, as long as the job doesn't require it - if that's the case then just study for the interview. If your job is deeply algorithmic then you shouldn't try and 'fake it' as it will bite you in the ass later.
1
1
1
1
Oct 26 '20
Try understanding in following sequence:
BigO notation, calculating time and space complexities.
Data structures, how they are used and where to use which and when.
Concepts: Backtracking, recursion, DP, hashing etc.
Algorithms. First layout the brute force approach for every problem you encounter, then optimize.
I’m following these right now, in a little different mixed manner.
1
1
u/dsound Oct 26 '20
Interview Cake and this course:
https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
1
1
1
u/WartedKiller Oct 26 '20
One thing that helped me a lot is learning “string” manipulation in C and sorting algorithm. Then go take a look at recusive function and redo the sorting algorithm.
1
u/stealthypic Oct 26 '20
I highly recommend doing a lot of CodeWars' challenges. It's really fun and you learn a lot from trying to solve it yourself and then comparing with other, usualy better solutions.
Also look for Advent If Code. Happens every December and it's a really tough advent calendar with code challenges. Passed years are also accessible.
1
u/Gibbo3771 Oct 26 '20
This post confused me a bit.
The first one was super simple, but took me way too long
This is absolutely fair, if it's a weird problem to solve (coding interview challenges normally are) then taking longer than normal is...normal. I bet the question was ambiguous as fuck as well, usually settin the interviewee (that a word?) for failure :(.
I couldn't finish the second one, in part because I wasn't very familiar with Python's class syntax and in part because I'm still not very comfortable with OOP.
What does this have to do with algorithms? It sounds more to me that you had to use a language that were not familiar with, and a concept you are not comfortable with.
It's great you want to learn more about algorithms, but I am curious as to what drew you to the conclusion that algorithms was the problem.
1
u/mutateddingo Oct 26 '20
Hey there, I have a BS and ME in Civil Engineering and am also trying to transition into a CS career. Just curious, how did your CE background affect their interest in you as a developer? I can’t afford a significant pay cut making the switch to a developer roll so would like to know how much they value your prior experience. Thanks!
1
u/throwaway4284168 Oct 26 '20 edited Oct 26 '20
Algoexpert.io they run through the example and actually code it, that is, if you get stuck and you want to see the optimal (and suboptimal) solution(s). Nice format/layout, I found the experience rather enjoyable. Its not really so "competitive" though? Which i think it could be lacking.. does feature a timer but it doesn't seem to really rank your skills as much as it teaches you what you need to know...
But they have a whole bunch of questions, neatly visible all on one page, in different level-of-difficulty categories.
Would personally recommend checking it out
Edit: keep practicing, even just voicing the logic and looking for recursion and levels of complexity. The way of thinking will become more natural over time!
Sorry, last edit!: Also figure out which learning style works best for you, optimizing for minimal time and strain lol. Youtube works well for me. I also like metaphors.. data structures are crucial.
1
1
u/waldemarsvk Oct 26 '20
Hi you can also check this out. https://www.codewars.com/
Basically you solve different coding tasks and after that you can compare it to other coders solutions. If you don't find any solution you can check the solutions of others too. You can choose the difficulty.
1
u/bonham000 Oct 26 '20
I can also vouch for AlgoExpert, which is one of the best interview preparation tools out there, in my opinion. I also went through Outco's program in-person several years ago and this was very beneficial for me (although it is more expensive). Another good interview related resource to take a look if you haven't seen it is TripleByte.
Also, I can add: don't worry if you struggle with the algorithm questions or even get rejected after interviews. The software interview process has a lot of drawbacks and often does not reflect the skills you actually need to work. Try to just stay focused with your process and keep practicing - you will find the right match with the right company.
1
u/festiveatom Oct 29 '20
Some companies do the timed code challenge just to see how you problem solve, they don't actually expect you to finish every task. Most of the time, though, when there's a timed code challenge like that, it's a red flag. Expect the work environment to be just as stressful. A company that demands that level of "perfection" from a candidate in the interview process is going to demand even more of their employees. Reasonable companies will give you a couple of days to complete a 2 hour challenge, not sit there with a stop watch.
What Algorithms questions did they ask you? Algorithms are actually pretty hard. There's a lot of practice problems on HackerRank.com. Working through the problems definitely helped me learn a little about them, but even after a graduate-level course I still probably couldn't pass too many job interview questions about them.
1
1
u/CheekyBurgerr Oct 25 '20
I'm also self learning Python and everywhere i look i see structures and algorithms, thanks for this question i will look into some of the suggestions.
0
u/ReginaldDouchely Oct 25 '20
It seems like a bit of a miss that you weren't familiar with the class syntax for the language you were tested in... did they tell you ahead of time it'd be Python? If so, yeah, you should have studied the basics in that. Python is pretty popular, but it'd still be unreasonable to be tested in a random language just in case you haven't worked with it.
Not knowing the syntax for the language you're being tested in isn't an algorithm problem, nor is it a "cracking the coding interview" problem.
0
187
u/Rub-it Oct 25 '20 edited Oct 25 '20
Urgokk congratulations on your first failure it means you are out there and trying, and persevering, and learning, and asking questions and getting better! Keep it up!