
Explain the time complexity of solving Two Sum on an unsorted array using both a brute-force nested-loop approach and a hash-table approach. Justify why the optimized solution is linear on average.
Why the brute-force approach is O(n^2)Why the hash-table approach is O(n) on averageWhat space complexity each approach usesWhen worst-case hash-table behavior matters