There was an error while loading. Please reload this page.
Solution Approach I first tried a brute force method using nested loops (O(n²) time). Later, I improved the solution using a hash map (unordered_map in C++), which gives O(n) time complexity. Key idea ...