We generally study most of the algorithmic techniques in academics like Searching, Sorting, Dynamic Programming, Greedy Algorithms, Divide and Conquer, Backtracking, etc. But below techniques are generally not taught and used a lot to solve questions in interviews and competitive programming.
In this technique we preprocess the array and make another array called prefix sum array. Prefix sum array computes sum of elements from index 0 to current index.
- Equilibrium index of an array
- Find if there is a subarray with 0 sum
- Maximum subarray size, such that all subarrays of that size have sum less than k :
- Prime numbers which can written as sum of most consecutive primes.
- Longest Span with same Sum in two Binary arrays :
- Maximum subarray sum modulo m
- Maximum subarray size, such that all subarrays of that size have sum less than k
- Maximum occurred integer in n ranges :
- Minimum cost for acquiring all coins with k extra coins allowed with every coin :
- Random number generator in arbitrary probability distribution fashion :
Two pointers is really an easy and effective technique which is typically used for searching pairs in a sorted array.
- Find the closest pair from two sorted arrays
- Find the pair in array whose sum is closest to x
- Find all triplets with zero sum
- Find a triplet that sum to a given value
- Find a triplet such that sum of two equals to third element
- Find four elements that sum to a given value
This technique shows how a nested for loop in some problems can be converted to a single for loop to reduce the time complexity.
- Maximum of all subarrays of size k
- Find subarray with given sum | Set 1 (Nonnegative Numbers)
- Anagram Substring Search (Or Search for all permutations)
- Count ways to reach the n’th stair
- Subarray of size k with given sum
BONUS TIP: Whenever you solve a problem, make sure that you analyze it properly. Here, the Analysis not something about its efficiency, “it’s about finding a pattern in a problem .” Have a practice of grouping problems under a category of pattern will make you better. This is because when you look at a similar problem again, your brain identifies the pattern instantly and just picks it up and gives it you. This seems to be quick and makes you feel a bit confident too.. Happy coding!!!
- Why You Should Become a Self-Taught Programmer?
- Frequency Measuring Techniques for Competitive Programming
- Algorithms Design Techniques
- Algorithm Library | C++ Magicians STL Algorithm
- Basic Laws for Various Arithmetic Operations
- A* Search Algorithm
- DDA Line generation Algorithm in Computer Graphics
- Line Clipping | Set 1 (Cohen–Sutherland Algorithm)
- Bresenham’s Line Generation Algorithm
- Mid-Point Line Generation Algorithm
- Point Clipping Algorithm in Computer Graphics
- Commonly Asked Algorithm Interview Questions | Set 1
- Anti-aliased Line | Xiaolin Wu's algorithm
- Mid-Point Circle Drawing Algorithm
- Exact Cover Problem and Algorithm X | Set 1
- Exact Cover Problem and Algorithm X | Set 2 (Implementation with DLX)
- Shortest Path Faster Algorithm
- Peterson's Algorithm in Process Synchronization
- Program for SSTF disk scheduling algorithm
- Dekker's algorithm in Process Synchronization
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.