As I'm doing some Hackerrank/LeetCode exercises, I'm actually enjoying solving these puzzles. I'm wondering if anyone who went through this prepping for an interview ended up being technically better overall. I know that I rarely needed this kind of skill in my career, but also I'm wondering if there were cases where I did need them and I didn't know.
Cheers!
1) Learning the algorithms. I agree with the general criticism that these algorithms aren't that broadly applicable. I work on data storage software, so we use a few relatively fancy data structures, but even so most of my day to day work isn't on the code that manipulates them. That said, I think succeeding at these contests (especially when they're timed) requires you to practice avoiding bugs, particularly off-by-one errors, and I think that practice is pretty broadly applicable.
2) Thinking in terms of data structures. The data structures that a program uses are a lot more important than the actual code. Some critics complain that programming contests teach you to write messy code. I think that the people who are really good at programing contests who write messy code (ime, it's more compact than messy) do it because they've trained themselves to look at a program and see the data structures rather than the code, and in my opinion that's a better way to think about a program.
3) Learning to get good at something in general. This is the main reward I feel like I've gotten from these contests. I think many skills in life (including job performance and career advancement) can be developed the same way: study the rules, study the best competitors to understand what's achievable and what techniques are available, make an attempt, try to understand the results you got, try to improve your approach, repeat. I think programming contests are a great place to learn to do this (among many others, of course).
1) preparing for an interview doing LeetCode puzzles two weeks before is like studying for an exam the day before. It's worthless. If you haven't been studying the subject for months (i.e., if you haven't been working as a software engineer for years), then nothing will make you pass the exam. And even if you pass the exam (because, you were lucky and the questions in the exam were the exact bits you just studied in the week before), you don't really know the subject: you'll forget what you studied the following week.
2) I can successfully avoid companies that require LeetCode interviews. I thought I would be out of the market if I rejected such companies, but it turns out that's false! In my limited experience, around 50% of companies out there do not require LeetCode-kind-of interviews.
Don't get me wrong, I do enjoy solving programming puzzles but only on my free time, not because a company is telling me to do so.
In Australia I have fortunately not encountered a company that uses these puzzles in interviews. I feel bad for my friends in America who have to practice them every time they switch jobs.
Don't fall for the hate people give. Every selective interview process gets hate. It's extremely useful for your development as a programmer.
Edit: I do think it's not good when there are bad interviewers. For example, interviewers who don't give you a chance to think, or expect you to know the perfect solution rightaway. Or just arrogant interviewers :(
Or let’s say you have a massive set of services you need to integrate with to solve your next set of business commitments for the coming year.
How do you hire folks who truly have the motivation and speed of learning to solve these areas on your team? Both are proprietary subject matters. Both haven’t really been done before and require a tenacious self-starter.
In that sense leetcode + team player/leadership qualities might make more sense.
Yeah it’s CRUD more or less 80% of the time re: code. But the ability to tackle ambiguity in an overwhelmingly large space and still be inventive: that’s what’s being tested. And as you get more experienced the technical assessment skews to system design which is also a good bar for just - how do you consistently simplify technical and organizational complexity?
It’s why FAANG + unicorns’ compensation is high. It’s a correctly-priced asset in the market. To the business these are important functions.
Does it have anything to do with pure programming for having fun’s sake? Why Linus created Linux? Only loosely.
It reminds me of when my college required linear algebra for my degree. Learning things that I knew without a shadow of a doubt I would never put to use again.
Of course, fizzbuzz is just checking if you grok some super basic programming concepts like logic, branching, and iteration.
So what if you want to know if someone knows a little bit _more_ than just the basics? It's the exact same story.
The ability to be able to work with algorithms and puzzle your way out of a problem is kind of important when you're doing some sorts of programming, especially when you need code that scales well (up OR down).
If you're really bad at it, you might write pessimal code that even overheats your regular laptop; but fortunately most people aren't quite that bad. ;-)
So in terms of testing and finding edge cases to handle, it's really eye opening how deep you may need to go. When I do LeetCode, I try to write my program once and if I fail a test case, I consider my attempt a failure and move onto the next question.
But otherwise, it doesn't make you a better overall programmer. There's no incentive to write maintainable code, and you're incentivized to get the code running as quickly as possible by trying to shave off milliseconds, which usually don't matter as much in real world situations.
I do more challenging work as a hobbyist than as an employee, by several orders of magnitude. The cause for that is that as a web developer the emphasis on work and capabilities is entirely around knowledge of tools. If fact it is pretty extreme to the point of people often telling you to deliberately avoiding writing original solutions to problems, even if quick and minor, if instead you can download an untested package from the internet.
See:
* https://en.m.wikipedia.org/wiki/Invented_here
* https://news.ycombinator.com/item?id=27310461
I usually excel at the leet code portion of the interview and then immediately bomb the next round of interview when I advocate for writing code, originality, and portability.
1. I think professionally testing algorithm knowledge is fine, but it needs to be one and done. I want a certification and I don't want to have to do it again.
2. This knowledge is largely useless in actual programming. It does teach me how to interrogate data structures and how algorithms work well with certain data structures. This kind of knowledge will only be relevant later in your career and at a certain type of company though.
So, am I better? Yes, I think I am, but I don't think I'd thank algorithms for that. I thank an innate desire to learn that happened to be briefly applied to algorithms and data structures. The hyperfocus on algorithms misses the forest for the trees.
* The company is cargo culting Google or it is Google, in which case it's cargo culting hunting down people like Larry and Sergey.
* The company makes decisions based upon safety in numbers. "Everybody" interviews this way, so if you're worried about justifying your process in future, it's a safe option.
* If this system selected me for a $200k / year job, it can't be all that bad.
* It does correlate somewhat with ability.
I have been writing code for more than 25 years now and graduated top of my class in CS. I also have a degree from a US ivy league school on top of my CS degree from europe. I developed and launched 4 succesful products. I won awards for my work and I’m a semi celebrity in my niche.
I recently went through several FAANG loops and did not pass their retarded leetcode questions. each time i had the feeling it had to do with not being FAST enough or not producing the EXACT solution the interviewer wanted.
what is funny is that I got one interview where the guy asks me to solve a problem that gayle mcdowell (cracking the code interview) spent ONE HOUR solving in a video provided as “training material” to candidates, YET they wanted me to do it in a few minutes WHILE EXPLAINING what i was doing.
the above is why I no longer participate in coding interviews.
for all those who think people who pass these interviews are “better” engineers: this particular FAANG has shipped broken SaaS products for years, despite having the “smartest” engineers on the payroll.
I think the types of companies using these tests are the big FANG type companies and they are mostly recruiting more junior people so for them 10, 15, or 25 years experience doesn't matter. They don't care how long you've been working just if you can balance a binary tree or solve NP hard problems in under 15 minutes.
So if you are applying for a FANG type job then yes definitely but the likelihood of you being picked is actually really low. Why you ask ? Because ageism is rampant in the tech sector so the FANG companies almost exclusively hire younger candidates (with 10 years experience you're not young).
What about other smaller companies using similar tests though? That's true but I've found most small companies that do these types of tests don't hire for some reason. I think they reject a lot of employees as they think they will get better candidates. So the likelihood of anyone getting a job there is really low.
I think it is important to know WHEN you're facing an algorithmic problem, and to be able to generalize your problem enough to recognize what kinds of algorithms might apply. But leetcode style questions as currently posed go way beyond that imo.
Basically with a bit of drilling, a competent programmer should be able to get the hang of those questions, and maybe the fact you can get competent at doing tricky, niche things is a useful indicator.
I wouldn't say doing leetcode would in anyway make you better at writing clean, well structured code, which is what we typically interview for in non FAANG. Probably does help sharpen your cracking out gnarly inner loop type coding skills i.e. better at writing a difficult function, doesn't do anything for how you would write the rest of the program.
However, in my experience those kinds of problems don't make you a better developer. They are almost the opposite of what you do day to day as a developer.
I've written more about it here: https://henrikwarne.com/2021/04/19/recruiting-software-devel...
I thought I was a good Ruby programmer, but preparing for a FB interview in Ruby, and bombing an earlier one, really showed me how slow I was with the syntax.
Leetcoding really improved my grasp of the language.
It's easy to say that such tests are useless, and they probably are as a tool for judging coder skill. However when I did a few of these it did open my eyes to a few common solutions that I could apply in various places in my code. If you read through an algo book you'll probably find a few things that are a bit surprising like Kadane's algorithm, or some things that you kinda know how to do but you need the last piece of the puzzle for, eg various graph algorithms (is there a loop etc).
I'd say the main benefit is that it illuminates what kinds of things you can solve and what kinds of things are tricky (eg knapsack), which is a useful intuition to have.
If you can do difficult tasks, you’re capable of doing easier ones.
Leetcode exercises helped me make coding a data structure to solve a problem, second nature.
It gave me a problem solving confidence boost.
Day to day, it will help you much less, but it comes in handy when you hit that use case Leetcode trained you for.
Like realizing that a trie is valuable when doing a prefix name search in a Contacts application. You might have seen it in a CS class, but you won’t “believe” in it until you’ve implemented it yourself.
Longer answer: I always enjoyed these types of questions, and I sometimes solve them in my free time, e.g. Google's Codejam. So when I interviewed I didn't need to prepare specifically for the technical questions. Therefore it's a bit hard for me to say exactly what contribution these questions made to my skills, because it's something I've always done. Also, it's probably not relevant for 95%+ of my work. But once in a while when I do a code review, I see some convoluted piece of code that does something that can be done in 3 lines, like transforming some data from one structure to another. I feel that doing those types of programming tasks helped me find the most straightforward solution in these cases, where other people might only find more difficult solutions.
By the way, a skill that is relevant to only 5% of my work is not as bad as it sounds. I'm currently finishing reading a book about presenting information visually. Doing presentations is probably less than 5% of my work.
From my understanding those brain gymnasiums make your brain work harder and you have to concerntrate for longer period to get them solved. They also open new ways of thinking about the world.
I've never felt the need to explicitly study for interviews. Given the wide range of programming tasks I've encountered over the years, along with countless hours spent reading programming books and magazine articles, I know enough to be dangerous, and where to look when I'm not sure. Simply being aware that there is somewhere to to look is half the battle.
- well, those are classic books written by people who know. You'll learn a lot of high quality material
- your future engineer peers (the good ones) will give a damm whether or not you know LeetCode puzzles inside out. They do care about you knowing the fundamentals
- LeetCode is short-term planning: bread for today hunger for tomorrow. Make your future self a BIG favour and stop doing LeetCode, and start learning from trustful sources (whatever the topic is)
I'll admit that and I found myself re-employing one of the things I learned to creatively solve a problem, however this only applies to my personal/passion project which is mostly shader-based and where algorithmic optimization knowledge like this is highly useful and applicable. In every day work however, and the kind of work I'm doing for companies 99% of the time it's not useful, as you'd expect.
If you're organised and manage your energy wisely I'd say you could prepare well in ~2-3 months. While a lot might not agree, I think that instead of moaning on how to avoid the technical interviews and how useless the questions are the time is better spent on focusing and getting it done.
The bigger benefit to me, however, was that I got more confident during the interviews.
So, no.
My feeling is that it didn't help at all, because programming competition and programming are quite different skills. But I can't say for certain.
What it doesn't train:
- Software architecture (do Factorio and/or systems design interview questions)
- Huge codebases
- Library integration
- Volume (aka lots and lots of code)
What it does train (YMMV):
- Precision: The goal is to write bug free code, this used to be a weakness of mine and now I'm less weak at it
- Simulating code in your mind: related to precision, I use the debugger less and my mind more.
- Finding ways to like the grind: nowadays I see data structures as micro-organisms or plants, they're so much fun to visualize that way! It taught me something about my personality (fantasy, whimsicality are my jam). If you know Vihart, that's how I think about data structures now. Because of this "epiphany" I suddenly find a whole new mode of liking abstract things that I previously didn't like that much.
- Learning how to make small programs that do something meaningful-ish and reason about them. Opening a file and doing a for loop and do some manipulation is IMO not meaningful enough. Tweaking a binary tree is, because it simply doesn't feel trivial. Normally I have this feeling when I look at large codebases.
- Practicing space/time complexity skills. This is super important, there have been moments where I really needed to rely on these skills because other engineers did some dumb things and where hogging the network or the CPU of the user's browser :/
- Muscle memory for the standard APIs of a language. My interview language is in JavaScript (on purpose because I'm a web dev). It's much easier now for me to write a map or a reduce. Before this, I needed to consult the docs, now I don't. I've subconsciously learned a lot of small little templates that allow me to write code quickly yet accurate.
- There have been weird moments where I did need to rely on data structures (e.g. creating an efficient trading bot or making a computer graphics application for drawing on a canvas in a performant way)
---
Is this the best way to get better at coding? No. But given that it does have some benefit to me and it might allow me to double or triple my income, why not try it? What I also like about it is that: if you know leetcode, then 50% of the companies open up to you. The other 50% are way more heterogeneous and the interview process feels too random. From the position I'm in, randomness is usually a bad sign (and sometimes it means I don't need to do anything to pass the interview, but that only happens once every 50 companies I apply for).
The problems are small, isolated, and usually come with an irritating edge case.
The puzzles are enjoyable though.
If e.g. you don't know what an hashmap or a balanced search tree is, or that you can find common items between two sequences or find a shortest path in a graph with non-negative edges in O(n log n), or that you can't (as far as we know) solve SAT, max-clique or subset-sum in polynomial time then you should not be programming software to be used by others.
Advanced algorithm design skill however is generally only useful if you are doing specifically algorithmic work.