What you should study for a successful interview loop

Any question related to computer science is a fair game in an interview, because believe it or not – you do need knowledge of most of these things for the job when working on a project. Although it’s not feasible to study everything, you can be strategic about the preparation and prioritize one thing over the other depending upon how much time you have for your next interview. … More What you should study for a successful interview loop

Dynamic Programming

The idea behind solving dynamic programming problems is simple – remember what you have already solved and use the already computed solution in case you are solving the same problem again. In other words, solve one problem only once and remember the solution to it so that you can quickly provide the solution without the need to solve the problem again. … More Dynamic Programming

Analysis of Algorithms | Big-O Analysis

For any problem, usually, there are multiple ways to tackle it. Solving a coding problem in an interview is no different. There are almost always multiple solutions to the given problem. Each solution has some cost i.e. time and space complexity associated with it. Your job is to identify various solutions, analyze their time & space complexities, discuss this with the interviewer, and implement the most suitable solution depending on the inputs and constraints. … More Analysis of Algorithms | Big-O Analysis

Stuck on a problem in coding interview? Here is how to poke the problem towards solution

When you get stuck in an interview, you have the opportunity to actually get maximum points from the interviewer as long as you keep the positive attitude and logical approach. Ideally, the interviewer would like to see the candidate struggle and then find the solution. This way, they are able to see how you tackle the problems in the real world. … More Stuck on a problem in coding interview? Here is how to poke the problem towards solution

What things you should know how to do in your programming language

The purpose of this post is to remind you of a variety of common things that you would need when writing the code in the coding interview. What you must do is to check the syntax of that thing in the language of your choice. I have listed most of the things that I have ever had to use across all the interviews I have appeared for. Some things are necessary for pretty much every interview while others are rare. I recommend studying everything even if it is a rarely necessary thing because I want to enable you to crack every coding interview. … More What things you should know how to do in your programming language

How you can crack every coding interview

It is definitely not easy, but you can greatly improve the odds if you nail the following approach. I am going to explain the key elements that you need to get right to crack the interview. How many times you solve the question, code it completely, but still don’t clear the interview? This post is an attempt to stop this happening with you. … More How you can crack every coding interview

Leetcode 15. 3Sum

As we have already solved “Two Sum” problem already, let’s reuse our existing knowledge to solve this problem. We know the target and we want to search 3 numbers. We know how to search 2 numbers, so if we fix one number at a time and look for the other two numbers using our previous solution that would solve this problem as well.

Prefer video over text? Watch the explanation here: https://youtu.be/MmhfOzYMYPkMore Leetcode 15. 3Sum

Leetcode 70. Climbing Stairs

Now that we know 3rd step can be reached directly from 1st and 2nd, what will be the number of ways in which we can reach the step 3? It would be all the ways in which we can reach the step 1 (because we can always take 2 steps from here to reach the step 3) + the number of ways in which we can reach the step 2 (because we can always take 1 more step to reach the step 3). … More Leetcode 70. Climbing Stairs

Leetcode #1529: Bulb Switcher IV

Certainly, a “Flip” is a must when the current status of a bulb at index i and it’s the target status are not the same.

Initially all bulbs are OFF i.e. 0 and when a bulb at index i is flipped, every bulb after (in the right -> direction) that bulb gets flipped. So it only makes sense to start getting the status of the bulbs correct int the left to right order. … More Leetcode #1529: Bulb Switcher IV

Leetcode #1503: Last Moment Before All Ants Fall Out of a Plank

The problem is a lot about observation. Observing and analyzing the ant behavior will reveal that the problem is way too tricky to understand but way too easy to implement. The idea is to think of the bigger picture and focus only on the paths of the ants. At any collision, think of it as ants transferring their responsibility … … More Leetcode #1503: Last Moment Before All Ants Fall Out of a Plank

Leetcode #1488: Avoid Flood in The City

When drying lake #L, it is only useful to dry it if it is FULL already. Otherwise, it’s just a waste to dry an empty lake. (Explained this in the code with a small example as well). In short, drying a lake #L only makes sense if it is already FULL and it is going to rain on that lake in future.

Which lake to dry on a day when there is no rain, can not be determined without knowing the rain sequence that is coming next. … More Leetcode #1488: Avoid Flood in The City

Leetcode #1465: Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

So the only task for us is to find what would be the height and width of each piece after all cuts and then find the piece with maximum height and width. Each cut in the cake, divides the cake into pieces with certain height and certain width. We want to maximize the area … … More Leetcode #1465: Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts