This is a simple but interesting problem, which can be easily solved with O(n2) time complexity, but it demands to reverse your logic to solve it in O(n) time. Problem: Let's say, there is an array arr=[1, 2, 3, 4, 6, 7, 8, 2, 5] Now we need to find all pairs of numbers, which … Continue reading Problem: Find all pairs
Tag: arrays
Difference Array
Today I am going to introduce you to a pretty cool algorithm, which would allow you to update multiple ranges in an array in O(n) time ! Let's say you got an array, and you need to update ranges of it with given values. So as an input you would receive a two dimensional array … Continue reading Difference Array