r/codinginterview • • Apr 26 '20

Why is there no clearly defined methodology for this ?

There are 8 million vague blog posts, book lists, videos, bullshit coding interview prep startups from EX-FAANG wankers looking to profit off this toxic interview process, coding practice platforms, some chick who claims to be an expert and wrote a book about it even though she only interned at most of the places she says she worked at, and on and on...why has no one ever just elucidated a clear-cut method for how to be successful at coding interviews?

2 Upvotes

11 comments sorted by

4

u/wodahs1 Apr 26 '20 edited Apr 26 '20

TLDR: you’re doing this wrong, here’s a question I got at google and how I used BacktobackSWE and leetcode to solve it.

You’re missing the whole point. You need to develop algorithmic problem solving skills. You MAY get a question that you’ve seen before on a Google interview, but it’s unlikely. I’ve done hundreds of leetcode and I can tell you that I’ve never seen the exact same question I studied on an actual interview.

This is because interview questions BUILD OFF of concepts that you need to have solidified in your tool belt. On top of that, you often get a word problem and need to translate that into a problem you’ve seen before.

Example from a recent interview of mine at google:

You’re a bank robber and you want to figure out how to unlock the safe. The safe is the type of lock that has many of those scrollable inputs. You know, when you lock your bike, some locks have 5 scrollable inputs with 0-9 on each scroll so that you can can input a password such as “12345”.

This lock has n slots and each slot only has 0 and 1 as an option. As a result, you can only have passwords like “001010101”.

When you get to the bank, the lock will be in a certain state. For example, say n = 3, an employee could have left it at “000” or “010”.

Suppose you know the answer state. That is, you know the state that will open the lock. Say it’s “111”.

You can only change one slot of the lock at a time. That is, you can go from “000” to “001” BUT NOT “011” because that would require moving two slots. You can however do “000”->“001”->“011”.

Finally, there’s a list of “safe” intermediate states that you’re allowed to be in so that the bank’s alarm doesn’t go off. You know what these states are.

For example, Starting state = “000” Ending state = “011”

list of safe intermediates = “010”, “001”, “100”

Your goal is to take these 3 inputs and determine whether or not it is possible to reach the ending state given the starting state and the possible intermediate states. Remember that you can only change 1 bit at a time.

ANSWER:

I had never seen this problem before. After the interview, I looked it up and couldn’t find it online.

Here’s how I solved it using the basics I was taught through leetcode and BacktobackSWE.

The first thing I did was boil the problem down to something more technical, because that’s what I’m used to.

Basically, given a starting string of bits, reach the ending sting of bits by moving one bit at a time.

The catch is that you have to make sure every intermediate step is in the list of safe intermediate states.

Ex) “000”->“011” Safe = [“001”, “010”]

Here I can do “000”->“001”->“011”

The naive solution is to list out every possible way to reach the goal state, and then checking to see if every intermediate state is within the list of safe states.

I recognized that this makes a good BFS problem. You can expand a state only if you haven’t seen this state before and if it’s in the list of acceptable states.

This makes the time reliant on n, the size of the strings, and m, the number of possible intermediate steps in the list.

O(nm) because for each possible string O(m), you have to consider its mutation which takes O(n). So you multiply them.

Here’s where those “BS” youtubers came through.

I practiced by watching BacktobackSWE. He prepared me for BFS. He helped me have the code ready to go whenever I see a BFS problem. I don’t even have to think about how to solve BFS anymore, I have the code memorized.

This helped me save ample time on the interview. Interviews at google are often a time crunch. My recruiter told me that that’s usually people’s biggest problem — time is important.

Anyway I got great feedback for this question.

0

u/malvin77 Apr 26 '20

Oof, another interview prep platform, but instead of ex-FAANG these guys are...CS undergrads?

0

u/wodahs1 Apr 27 '20

CS undergrads that prepare the way backtobackswe has are pretty qualified to teach others the material. I already cracked FAANG using his videos so I guess I'm proof of that.

1

u/pokerface0122 Apr 26 '20

It's not that deep, any of the coding platforms will do the job, it's just what you like the most.

As for the most basic, just go through popular leetcode questions, that's enough.

1

u/malvin77 Apr 26 '20

Except it’s not enough though...what’s the idea, you hope you practice the right questions ? You memorize the solution approach of each type?

2

u/pokerface0122 Apr 26 '20

no, you pick up on patterns and build your algorithmic solving skills

1

u/bparanj Apr 28 '20

I have created articles on this topic. The following articles are the most relevant to your question.

Problem Solving Techniques for Coding Interview

In a coding interview you have to demonstrate to your interviewer that you possess several key skills. The ability to rigorously formulate real-world problems. The skills to solve problems and design algorithms. The tools to go from an algorithm to a working program. The analytical techniques required to determine the computational complexity of your solution.

How to Solve New Problems During Coding Interview

In this article we will discuss the strategy to use when you have to solve a new problem that you've never solved before.

How to Develop Your Pattern Recognition Skills

The ability to recognize coding patterns in the solution is critical to build the basic blocks that can be combined to solve new coding problems.

How to Study and Practice for Coding Interview

Both study and practice are essential. There is no shortcut. What do you need to study for your level? Decide on the scope. You already have a prioritized list of topics to study. You now know what to study, let’s see how to study.

How to Develop Your Own Toolbox for Solving Coding Problems

When you’re studying, don’t just look at somebody’s solution and just type it in. You see that it runs and you just move on to the next thing. You will not learn anything by just typing in somebody else’s solution you found online. You don’t know the reasoning behind why they solved the problem that way.

How to Practice Coding Problems

Once you acquire the basic concepts, it is time to apply the concept to solve a problem. This is a challenging step in solving the problem. You will see the right way to go about tackling coding interview problems.

How Many Hours to Spend on Practice?

It really doesn’t matter how long. If you practice with your fingers, no amount is enough. If you practice with your head, two hours a day is plenty. Improvement requires you giving the task your full attention. One hour of intense and focused practice is better than 8 hours of practice interrupted by distractions.

What is the Right Approach to Learning to Code?

There are different ways to learn programming. We will consider the different approaches and fit them into the Bloom’s Learning Taxonomy grid.

How to Ace Programming Interview

Mastering the technical interview requires creating an action plan for study and practice. In this article, we will discuss things you need to do to master the coding interview.

Practice is the Key to Success

In this article, we will cover two different kinds of practice naive practice and purposeful practice. The right kind of practice plays a big role in acquiring the coding skill and achieving mastery in programming.

A Field Guide to Algorithm Design

How do you choose algorithm from your toolbox suitable for tackling a wide range of computational problems? When putting it into practice, you might find the sheer number of algorithms, data structures, and design paradigms daunting.

1

u/malvin77 Apr 28 '20

Hey man, what do you charge for mentoring?

1

u/bparanj Apr 29 '20

I am not charging anything right now. My goal is to talk to 100 people about their frustrations and challenges. I have spoken to about 12 people so far and I have provided them a customized action plan for their situation. You can schedule a call with me here: https://go.oncehub.com/BalaParanj

1

u/discodisco195 Apr 30 '20 edited Apr 30 '20

1

u/malvin77 May 01 '20

Thanks for actually answering my question.