Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How does one have the mindset to study for coding interviews?
52 points by lowiqengineer 5 days ago | hide | past | web | favorite | 51 comments
I'm considering starting a new job hunt, but I'm out of practice. Unlike most folks, I still haven't gotten into competitive companies after doing ~250 or so problems (perhaps because of my aforementioned IQ leading to an inability to problem solve), and I'm not interested in companies that do alternatives to coding interviews as they generally pay significantly worse than what I'm expecting, but whenever I do Leetcode problems I frequently dive into the depths of depression and self-harm because I often can't do Medium problems. I've done CTCI, but that isn't as effective in the market now.

I'm genuinely concerned I might harm myself further if I attempt more study, but at the same time, I need to fix my compensation trajectory or else I'll be in the same boat later. What do you use to avoid this?

I lost my software engineering job a year ago. In my late 50s I sunk into a depression. A resource that helped me get back on my feet was the works of Dr. David Burns. His website is https://feelinggood.com. He also has a book "Feeling Good: The New Mood Therapy" and a podcast. In my case the feelings of hopelessness and depression that stemmed from my job loss were due to distorted thinking. For example my thinking was along the lines of "I've lost my job, I'm old, I haven't interviewed in decades so no company will hire me, I'm doomed". In reality that was distorted thinking. Sure some companies might practice age discrimination, but not ALL of them. I may be older, but I also have years of experience. It turned out that after about 4 months I found a job with a better company with a pay increase. There is hope and I hope this comment can help you in some way.

Leetcode interviews are more of a sadistic entrance ritual than anything approximating a fair gauge of skill or experience. I see no other reason to make proven developers study textbook problems during their free time (they sure aren't implementing knapsack algorithms from memory at work).

It often goes unmentioned that these interviews test the wrong skills for software development and even instill bad practices. To wit, those artificially handicapped online IDEs force you to memorize language APIs which any real IDE would handle for you -- forget that the JS lowercase string call is "toLowerCase"? Too bad. Also, since time is of the essence, and no debugging tools are provided, you better be using an interpreted language (read: JS and Python -- and really only the former unless you can import the correct libraries) and littering your code with print statements.

Other companies opt for the ostensibly fairer "take home CRUD app assignment" but this too is a facade to lend credence to a preselected candidate pool. No matter how well you complete the assignment with all enterprise grade best practices, you'll still playing the lottery (and this time with a five hour time sink).

Bottom line is don't interpret a lack of success in this draconian system to a personal defect. Ideally, seek employers who assess candidates fairly and qualitatively.

You need to spend some time on mental health. if you need help, get help. either stay at your current job or take a new job that you can get now. in either case you need to figure out how to deal with stress and how to value yourself. if you really are going to self harm when you struggle on a freaking leetcode problem, how do you think it’s going to be if you actually get the job you’re aiming for and it’s hard every day?

> when you struggle on a freaking leetcode problem

I'm all for the message of "get help if you need it," and it sounds like OP needs the help of a professional, so I upvoted your comment. But minimizing the triggering event is not helpful; the things you see as trivial or unimportant might be insurmountable or critical to someone else.

I could have worded that better. my point is not to minimize the stressful situation, it is that the stress isn’t going to end when leetcode is done.

weirdly i'm usually fine on the job, I don't feel the same way at all. I'm generally at ease even.

It's tough, it's like I feel attacked by the fact that I can't solve these in 5 minutes like the other folks I see on Linkedin.

(Didn't read whole thread) Are you sure you 'have a low IQ'? Did you take a full scale test (WAIS etc), or even something like the Wonderlic?

If you want a Wonderlic type normed test - get in touch.

And when I'm on Facebook looking at the best part of other people's lives, I compare it to the worst of my life, and get depressed and discouraged. Thing is, other's aren't usually sharing the worst of their lives, so I'm making a comparison that's unfair to me.

It sounds like you are tying up a lot of your self-worth in solving these problems "in 5 minutes", and there a few things to unpack. First off is that "5 minutes" is a drastic exaggeration, and even if it isn't, standard interviews length is either 45 minutes or an hour - you get the full time, to work through the problem. So don't sweat the timing.

Even if you can't solve the problem, no one but you sees your leetcode performance, so just because you feel like you're failing, that's a feeling which is all in your head and it's trying to trick you into giving up. Don't let it. No one is getting hired solely on the basis of their leetcode profile.

(If you've already shared your leetcode profile with all of your friends, and/or feel like having a strong leetcode profile is going to make you a more attractive interview candidate, then make a new username not related to anything else you do online using an anon mail service (eg mailinator.com). Then, if you still feel the need to show off your speed on your leetcode profile, copy and paste the working solution from that username into your 'official' leetcode account.)

Instead of trying to rush through and do 100 problems per day, sit with one problem, for a whole month. Use different algorithms, do different languages, go for runtime speed efficiency, go for memory size efficiency. Use leetcode as a tool to help you.

Another thing to understand is that a large component of interviews is simply luck. There are only so many permutations of sum/sort/median/topN/bottomN/count possible, so during a real interview, if you get a question that's similar to one you've solved before, then a solution comes naturally. What leetcode really is then, is a gameified playground to see a bunch of variations on a theme, in order to raise the chances you see a similar problem during an interview.

Echoing other commenters about the subject of mental health - find a therapist to talk through this and other things with. My life's been better for it, and it absolutely helped me to get my life in the shape it needed to be, in order to get a job at a FAANG company.

People always show their best side on social media sites, especially LinkedIn. Trying to measure up to an image that someone has crafted of themselves to get a job is somewhat like believing that the pictures people post on Instagram match their daily reality. You are walking into a well-known trap.

Trust me - as someone who listens to coding candidates on occasion, the majority do not just come in and whip out answers in a couple minutes. Those people are rare. And we sometimes like the slower candidates better because we get to see how they think instead of seeing just a quick answer.

The genius candidate is one with the quick answer but gives a slow answer :-)

> It's tough, it's like I feel attacked by the fact that I can't solve these in 5 minutes like the other folks I see on Linkedin.

Honestly, I'd recommend avoiding LinkedIn. It's completely devoid of any personal aspect to the work people do -- it's all business-this, company-that. There's no such thing as a post that's not spun in some positive manner.

As others have mentioned, in short, it's idealized. Plus, the skills that other people have are not necessarily the same skills YOU need to succeed. That includes Leetcode problems. Which, by the way: if the company cares about that kind of thing at an interview, they probably have that same sort of mindset during the job. Not guaranteed, but keep that in mind.

I struggled with impostor syndrome for a good three or four years, despite objective successes in my programming "career" as a student. I think that finding your own value, and distinguishing that from the skills you need to succeed, AND convincing yourself that you can get those skills, is the golden ("growth") mindset.

For example: math. (undergrad CS: calc, etc.) I tell myself I'm not good at math, I struggle adding basic numbers. but I've either 4.0'd or got 90%+ on midterms or just _passed_ enough math classes that I know this isn't true. How? I realized that math is literally just practice. That's it. Work in = work out, and if you get stuck, it's about correcting false assumptions.

That particular realization allowed me to embrace the (honestly terrifying) interview process a bit easier. Leetcode isn't about "grr get this problem perfect otherwise you're trash". Leetcode is about "okay, look, we have 20 minutes to see how good of a programmer you are, here's an intentionally hard problem. how clever are you. how fast are you. and do you fit our mold". THATS IT.

So, what could you do?

First, mindset. I've been doing iOS programming for a good 4 years now, but allll that work makes me worse at Leetcode, because I over-optimize for cases that don't matter. Realizing this made me slightly better at Leetcode. Only slightly.

Remember, Leetcode is just tiny, intentionally hard problems. It doesn't represent your skill as a programmer, just your ability to express a small subset of programming skills. And honestly,getting those skills is hard. I don't have an answer for that. Maybe try to analyze each problem, figure out what it's trying to test you on, then learn that topic from scratch.

Sorry for the ramble lol, hope it was helpful

I’m going to echo a few other comments on here and say that, although it may frustrate you to hear, focusing on your mental health is the urgent priority here—-but also, thankfully, something that will have positive side-effects across many domains.

As someone who has struggled seriously with self-harm in the past, this is not just a regrettable by-product of coding problems; this is a significant attempt by you/your body to regulate an environment that feels out of control, to cope with overwhelm, to distract yourself from facing something else—-ymmv, but until you work on understanding what triggers this (just coding? Other things too?), and develop tools for dealing with situations that provoke these intense feelings, this problem will re-occur in one form or another. Essentially, it’s too soon for a focus statement like “get better at leetcode” because the problem statement hasn’t been defined yet. That’s something you (and a therapist and/or workbook, online resource etc, if money is a challenge) can do together.

Now the good news: not only can you address this, but doing so will have amazing and unforeseeable benefits in more areas than just coding. This stuff never fully disappears, but I can now look at a passing thought to hurt myself as a “check engine light”—-it does not have power over me, it occurs seldom, and if it does, it means something needs addressing.

Best of luck.

I recently got into one of FAANG & the following are the steps I took to get there:

- Create a study curriculum.

- Each topic in the study curriculum should contain both reading & practice material.

- The reading material tells you about the data structure or algorithm and practice lets your reinforce what you just read.

- Spread this over a long period of time say 6 months.

- Practice everyday, I cannot emphasise this enough.

- Limit to about 2-3 hours a day.

- Give mock job interviews weekly or bi-weekly. See https://www.pramp.com

- Be kind to yourself these questions are hard on purpose.

You will notice a gradual improvement in your problem solving skill and general knowledge about the problem space. You might even begin to enjoy it (that's what happened to me). Diving blindly into just solving problems is a poor strategy. The key is balancing reading & understanding the data structure or algorithm with solving actual problems.

What did your study curriculum look like?

I created my curriculum using the topics in the book: Elements Of Programming Interviews In Python https://www.amazon.com/Elements-Programming-Interviews-Pytho...

You need to figure out _why_ you can't do medium problems. If you can solve easy ones, it means you have the fundamentals down, and probably just need more exposure.

250 sounds like a lot, but I'd also be curious how you do the problems, and why you're having issues.

Where are you getting stuck? Are you looking at the answers immediately? Or are you struggling through the problem, and only peeking at hints as much as is needed to make a breakthrough?

Do you think through and recognize the patterns (two pointer, greedy, dynamic, etc) that are needed to tackle the problem, or are you just jumping into code instantly?

What do you do when you get stuck? Do you confidently ask for help, knowing hints are part of the game?

How's your timing? Are you getting in a brute force solution and an optimized one?

Addressing these concerns will reveal where you need work, and then you can continue to get better without being too affected by your current state. Remember, no one was born knowing how to solve these problems, so you can always get better and reach your economic goals.

Small plug -- we created AlgoDaily (https://algodaily.com) to teach programming interview skills using a visual, patterns-based approach. The lessons on approaching the interview and how to prepare might be especially helpful.

in my experience, easy problems basically test how well u know the language u code in, they generally involve no knowledge of algorithms or ds. Medium problems generally involve being comfortable applying algo & ds fundamentals to solving problems. Generally, u can solve a medium problem pretty easily in a bad way but u can refine it to whatever degree your skill permits you, they key here is to understand things like space time complexity of your solution and seeing if you can refine it

I think I'd agree, but my argument is that going from a medium problem solved "pretty easily in a bad way" to a "fully optimized and efficient way" is easier than most people think. There's only a dozen or so patterns needed.

As an example, if you know the two pointer technique (https://algodaily.com/lessons/using-the-two-pointer-techniqu...), you're well on your way to solving at least 1/3 to half of array problems in a performant manner.

Some friendly feedback: I clicked through to your article about the two pointer technique and, AFAICT, there's nothing for me to do or read here. It says "In this guide, we'll cover..." but it's not clear how to actually view the guide. I'm guessing - without having clicked around at all - that my next step would be to create an account and visit the page again, but that's not at all clear to me as an unauthenticated user.

I do see a small "Login" on the bottom right of the page, as well as "Sign in" and a highlighted "Upgrade" at the top. But there is no CTA telling me what my next step should be. Maybe users of your site who land on this page will know what that step should be, but you might want to add some direction for people who randomly land on it via SEO/SEM or links on forums.


ETA: in a search for some action, I clicked all over the graphic and on a couple phrases in the intro to see if they would take me somewhere. If you're tracking clicks, it might be worth looking at whether other users are doing similar things.

Thanks so much for the heads up :-) It's amazing how much of the user's perspective you miss when you're heads-down in code all day.

I've added some navigational indicators to hopefully make it a little clearer that you can press the footer buttons or swipe on the screen. Appreciate the friendly feedback!

I had the same experience; at the very bottom of the screen are "next" and "back" buttons. But it took me a while.

I hear you. And there is good advise in the comments, but one thing I'd think you should also explore is your emotional response when you hit the harder parts of a problem. Sometimes, it is not the lack of knowledge or understanding of a subject, but the emotional response (subtle anxiety, anger, stress etc) that hinders progress when you hit an uncomfortable stage in problem solving. To add to it, leetcode and interviews have the added pressure of time limitations.

Observe your emotions - there may be a completely different solution to your problems.

Solving stupid leet code problems doesn't make you a better engineer. Try putting more effort in learning best engineering practices, read books, blog posts and try to implement them in your current job. Don't over think about compensation. Find a company that has good work life balance instead. Trying for more compensation is fine, but you can do find a much fulfilling job if you try to make yourself better.

> Solving stupid leet code problems doesn't make you a better engineer.

If companies use it for hiring screens, it does, indirectly: work experience is the main thing you need to be a better engineer, and the more time you spend working instead of spinning your wheels trying to get hired...

You are right, I totally understand that. The OP is depressed about not being able to solve medium problems. In that case it is better to avoid the rat race and try and becoming a better engineer is the best option.

And honestly, working with people that can’t solve problems in a simple way is a nightmare. Leetcode at least encourages this.

Doing push-ups every morning does not necessary for your success. It just helps you stay fit. Same with programming puzzles. It won't help you directly during solving your daily problems, it's just push-ups for your brain.

If you don't think there's something seriously rotten with 50+ companies selling "interview preparation" and all sorts of randoms selling you their get-into-Google courses, books and Youtube videos, you're not really paying attention. You should take it as a sign that these parts of the industry are FUBAR and steer well clear. Herd thither, me hither. Stop copying what the pseuds are doing, come up with your own vision and follow it wherever it may lead.

Assuming you're not fresh out of college and have plenty of experience (and skills to go with it), find a job that doesn't put you through this dumb grinder. Odds are it'll be a job you'll actually enjoy doing.

> I'm not interested in companies that do alternatives to coding interviews as they generally pay significantly worse than what I'm expecting, but whenever I do Leetcode problems I frequently dive into the depths of depression and self-harm

Maybe getting a lower salary is very well worth it if it lets you avoid the self harm and depression. SE salaries in general are pretty good so even if you’re in the lower end of the scale it’s decent. Not everyone can earn 300k total comp by working for the usual suspects, earning 80–100k if you don’t live in overpriced cities/countires is still a pretty good life.

Honestly I'm fine on the job and I'm usually not stressed like I am when I do leetcode. I'd be fine keeping my current gig but the TC increase even if/when I get promoted is lower than the average Google new grad offer.

Do as many interviews as you can and you'll start to see the same problems over and over. Treat it more like a fun coding game and think of it less as an interview if you're the type to psych yourself out. Identify what you're weakest at -- be it recursion, trees, systems design and focus on improving in specific areas. You could also create a plot of problem type and measure success/failure and then weight each category based on frequency in order to determine what to study. But it might also be better to take it day by day and not stress to much about the exact results too early on as you warm up.

i think first of all, solve problems for their own sake, enjoy the process, learn the solutions, that is the surest way to getting better at it (or really anything in life) and getting better as an engineer as well. If your goal is "i want to get good at these stupid puzzles so i can work at google and make alot of money", you will most likely fail. When i first started leet code, i had no competitive programming background, i didn't really even remember any of the algo & ds stuff i learned in college a long time ago, but i kept at it, i used to think about some medium problems for a couple days or more (I knew back then people who had a shot at google could solve medium problems in an efficient manner in like 10-15 mins) but that never discouraged me, even if i didn't get a shot at FAANG or whatever, i knew working hard and thinking about this stuff would make me a better engineer. After 7 months of work, i could solve a-lot of medium problems in around 10-15 mins in an efficient fashion and i actually look forward to solving LC problems whenever i get an opportunity. Other than leet code, i regularly study CLRS (i love this book). I guess my point is, either learn to love problem solving, or apply to places that don't value it because its hard to become good and compete at a high level if u don't intrinsically enjoy something. Don't tie your self worth to your IQ, don't get depressed because you can't do something, i'm sure u have a job, so just keep at it and try different approaches to learning this stuff.

I spend 2,5 month preparing every workday additional an hour and in weekends 10-15h (the whole weekend).

I failed the first phone interview because I was absolutely unable to guess what he was looking for.

2 years later again 2,5 month preparing for it. This time also large system design. I make it to inside. I still not in.

It is emotional stressful. That's how it is.

Start with this: https://www.educative.io/courses/grokking-the-coding-intervi...

That covers a lot of patterns you can typically use to solve a problem. Keep practicing and don’t lose heart. Use mock interviews to get valuable feedback. You can do it.

Honestly I would suggest stop looking at LinkedIn or CSCQ subreddit most people are just sharing there wins not losses and theres nothing wrong with that what is not okay is that it makes some people depressed that because we start comparing ourselves and that leads to depression. Honestly just focus on your goal keep motivating yourself

Yeah, I stopped going on CSCQ years ago because I knew it was just making me more depressed. Still, I know a lot of successful people personally who privately believe I'm a failure for working at the FANG i work at so the net effect is the same unfortunately.

Never think negative it hurts and let those people believe they can't face you so they'll keep believing. Just Believe in yourself and I always think you'll do your best

Just know you are not the only one going through it. I know plenty of multi year developers that have to deal with it, and they walk away wondering if their worth anything. It’s definitely a gauntlet and it’s tough on everybody.

Why are you so motivated by high pay, that you fear harming yourself? Just go for companies with a simpler interview process and attempt FANG after a couple of years of practice

I currently work at a FANG.

I don't think it's so much the high pay as much as it is that my peers look down on me because of the FANG I work at. I've practiced for years already (to fairly mediocre results).

Take up some volunteer work, change your peers, iq, social prestige and money are not the key to happiness. You can always leetcode and try to improve but not at the cost of your mental health.

It's not possible for everyone to be at the end of the curve. Be content with what you can reasonably achieve.

If it helps, maybe move somewhere with a better wage to cost of living ratio.

There's a simple hack for non-FAANG job coderpad interviews.

Just do several interviews in a row to learn what the common questions are. Then memorize those 3 or 4 solutions.

There's been a move this year to fully using the 1 hour coderpad period with a large problem, so you really need to go in with a prepared solution. (Thanks a lot, a(7) interviewers.)

As one of my friends said, "Interviews are a lottery." So do your best, then move on to the next one (see above.) Don't take it personally, just keep improving.

Also, if an interviewer says, "it doesn't matter if it runs or not" or "syntax doesn't matter", assume they're lying and fix it. (Again, thanks a lot, a(7) interviewers.)

Sorry, but I couldn't find a page named `a` in section 7 of the manual ;) what does a(7) mean?

a * * * * * *

Speaking of assholes, your recent comments have been so full of assholery that I banned your account. I decided to unban it, and just warn you instead, because you've also posted interesting things.

It's dismaying and shocking to me that such an active HN user would feel free to poison this place as badly as you have been doing: attacking other users, pompously dissing the community while participating in it, denunciatory name-calling...none of this is ok here. If you want to participate in the commons, please stop pissing all over it.


Edit: it turns out we've been through this multiple times before. If you want to continue participating here, it's time to start doing so respectfully.







If I'm supposed to feel dumber, it's working.

Looks like an (unusual) abbreviation for 'asshole'

I thought it meant like 7 anonymous companies (‘a’ being a function that takes in a param) that he/she had to go through. We’re dealing with a real weirdo here (or a real a(7)) :p

Sometimes you gotta take the good with the bad.

Ha you're obviously right. Did you deduce that on your own? I think I immediately excluded that from the set of possibilities because well... why wouldn't they just write asshole?


Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact