Don't miss these DSA question patterns
As all of you know that for cracking the interview round DSA is required. And the most important part is to practice because practice is the key to cracking the interview but some tips help you to memorize some important patterns and help you to think of the solution easily.
1. Sorted Array
In most of the questions when the input is given as a sorted array or list then it is a good chance that Binary search can come into the picture and we will get the answer by binary search. And if there is a constraint of finding the answer with O(logn) Time complexity then also we will get the answer by binary search.
Example -
Searching in a sorted array
Finding pivot
Finding a target in the rotated sorted array
Finding peaks in mountain arrays, etc.
2. When the range is from (1, N)
In any question, if the range is given from (1, N) or the answer is lies between 1 to N then there may a good chance that the question can be solved with the cyclic sort which is a sorting algorithm. If you get the question with the range from (1, N) then you can think of the cyclic sort.
Example-
Finding duplicate number
Duplicate in the array, etc.
Tip: Always try to optimize the brute-force solution
If you are solving the question then it is commonly a good practice to think of the brute-force solution first then you can optimize the solution according to the given constraints, required time complexity etc.
If you find this helpful then you can follow me...
#WeMakeDevs #productivity