Technical problem-solving approach

1. Listen/Read

2. Brute Force

3. Optimize

  • Check for the unused information. Eg. the given array is sorted, the given matrix is a square matrix.
  • Make note of the time and space complexities and check if you can optimize it by reducing the time and space complexities.
  • Check if you can alter the data structure so that the algorithm can be faster.
  • Check if you can use a hash table to solve the problem in a better way.

4. Walkthrough

5. Implement

6. Test

  • Do conceptual testing which means go through your code thoroughly and check if it will solve the problem as intended.
  • Check whether the loop starts with the proper value and exits the loops the right time. Prevent any deadlocks.
  • Check for the code which is not standard and remove it.
  • Test the code with a small test case which will save time and make it easier to solve the problem manually.
  • Check for the special cases(null values, extreme values, multiple and single elements) and edge cases.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store