### Rotate Array - Leet Code Solution

Problem Statement Given an array, rotate the array to the right by k steps…

March 31, 2020

Its every software engineer’s dream to work with the big FAANG companies (Facebook, Amazon, Apple, Netflix, Google). Their interviews are considered to be very hard. Lets look at what these companies expect from the candidates in terms of interview performance.

Below are some points on which these companies evaluates the candidate

How you assess the problem and arrive at a solution by identifying the right data structure/ algorithm.

Its about how you understand the problem, and how you arrive to a solution. Its essential to solve the problem upfront. But, there can be many approaches to solve the problem. Candidates are expected to explain their solutions, and the choice of choosing the right data structures is very important.

As I explained in Never try to jump to the optimal solution first, you should never jump to the best solution first. And, do not jump to coding. You need to explain your thoughts or solutions to the interviewer. And, there will be a discussion to understand your approach, and you should be aware of the complexities of your approach. It is closely observed that how you are able to find issues in the approach, and how you are able to come up with solution to that.

Some points are:

- Using data structures for optimal efficiency
- Provide multiple algorithmic approaches to single and compound problems
- Identified optimal solution for time-space tradeoffs
- came up with optimal solution for special cases

While writing code, you need to use best practices available for coding. Like, structuring the code, how you modularize it, generic functions, naming conventions etc.

Remember, you can write any code with one large piece of code in single function. You need to write it in such a way that it is maintainable, easier to refactor and easy to read.

Some important points are:

- Write clean code
- well structured code
- address potential errors
- write proper utility methods which can be reusable
- use good design pattern
- understand constraints and trade-offs
- Easy to understand and extend

How fast are you in assessing the question, identifying the right approach and coding the solution.

You are expected to solve one or two problems and with complete code. And, they generally has fixed time interview. Example: Google has 45 minutes for each interview, and it can not exceed this time.

For this, you need more and more practice. Keep an eye on time, while solving problems. Although, this looks looks trivial. But, this is very important factor in deciding the selection for candidate.

Some points are:

- How quickly you came up with solution
- convert ideas into code/action

Your ability to communicate your thought process and ask the right clarifying questions.

You are not expecpected to keep silent, and start writing your code in one go. You are expected to speak from moment you hear the question. The interviewer wants to hear your thoughts. If you are thinking about the problem, and don’t want to speak. Convey this to the interviewer that give me few minutes.

At every point or stages, you are expected to explain your thought process. And, your ability to ask write questions is very important here.

Some points are:

- Ask write questions, gather requirements
- Show robust comprehension of problem
- Identifying supplemental contingencies/challenges
- Provide examples and/or alternative explanations to clarify rationale
- Communicate your code/algorithms well in a way that left no room for confusion

You are not expected to write test cases. But, you are expected to test your code for all good and edge cases. Before hand over your code to interviewer, you can explain that this is my code. But, let me run some test cases.

By running test cases, it means you are trying your code with different inputs. It gives very good impression that you are concerned about the bugs in your code.

Some points are:

- Error check on boundary conditions
- write fault tolerant code
- Tests covered several corner cases
- Tests are simple but thorough

Problem Statement Given an array, rotate the array to the right by k steps…

Problem Statement You are given two non-empty linked lists representing two non…

Problem Statement Given a string s, return the maximum number of unique…

Problem Statement You are given an n x n 2D matrix representing an image, rotate…

Problem Statement Determine whether an integer is a palindrome. An integer is a…

This algorithm is very useful for large input. And, is quite efficient one. It…

In this post, we will see some of the frequently used concepts/vocabulary in…

System design interview is pretty common these days, specially if you are having…

Introduction You are given an array of integers with size N, and a number K…

Graph Topological Sorting This is a well known problem in graph world…

Problem Statement Given a Binary tree, print out nodes in level order traversal…

Problem Statement Given an array nums of n integers and an integer target, are…