I was reading the most voted answer from here: Difference between Divide and Conquer Algo and Dynamic Programming, but I don't have enough reputation to comment so I have to post a new question.
My question is: why is the overall time O(n)?
To my understanding, finding an element from an unsorted array of size n can cost time n.
And in the case of finding the fibonacci number, the worst case to check if a number is in memo could cost n time, so the whole algorithm will repeat n times, and each time it'll search for the number once, which costs n time. Then the overall time should be O(n^2) instead of O(n).
Could anybody point out where I misunderstood? Thanks