General

How to do well in coding interviews !

During the coding interviews, it is generally expected to write the working code for one or two problems. The efficacy of the solution is contingent on your problem solving and coding skills. Conventionally, this type of algorithm and data structures heavy coding is not used in the usual coding in the work and it demands some practice before the interviews. Leetcode is one of the great sources for the practice and its premium solution really helps to gauge the level of the question for a company.

Here are fews tips that helped me during my interview preparations to ace the interview questions asked from the FANG companies:

  1. Using interpreted language, helps in writing code faster compared to compiled languages. That’s why I prefer to use python for these types of interviews where I need to code faster
  2. While practising, try to solve the problem by yourself first and it is ok to write the code with a brute force approach without looking at the solution. After you have running code, you can check codes from the other programmers and understand their approach. Compare their approach to learn from it. It is very helpful to see the multiple approaches for the same problem
  3. Solving object oriented design in python is a little tricky since functions are the first class member of the language. Java is best for these problems but we are planning to add example of OOPs with Python also in our design interviews blog
  4. Keep a working knowledge of all the data types provided by the language and it is helpful to know the complexity of the operations in these data types . For example, in python, you can use the deque, counters, itertools, set, queue,heapq to do the faster coding
  5. Read the question at least twice to understand. Make sure to understand the right type of input and output parameters to the function also. 
  6. Try to solve the problem completely on paper before starting the code in the editor. Run your solution with 1 happy and 2 edge cases. Discuss the approach with the interviewer before writing the code
  7. Be verbal and keep communicating with the interviewer during the course of the interview and treat him as a peer
  8. Ask good questions at the end of the interview and have a good smile during the interview
  9. Keep practising. Some of the minor tricks that I use while writing code in python are as following
    1. Use multiple operators and operand while in conditions  e.g. If 0 <= start < 10 and 0 <= end < 10. I generally use this to make sure we are not in out of index in the case of grid or metrics problem when we have choice to move in multiple directions
    2. Use Min/Max instead of if condition whenever possible.
      1. E.g. If result < newValue: result = newValue to result = min(result, newValue)
    3. Use sets for the intersection or unions between two lists
    4. Python’s heapq doesn’t have support for Maxheap. To use the max heap, insert the values with a negative sign. 

      10. Last but not the least, have confidence in yourself. Always believe that you are going in the right direction while thinking about the solution. 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button