Improved an algorithm from O(n log n) to O(m + n)
Mar 3, 2024
Recently, I’ve started reviewing algorithm problems I did in the past in order to find better solutions.
First one
Today is this one.
Improve one
My algorithm was O(n log n) before, but it is O(m + n) for now. The trick is inserting elements from the last of arrays.