Find and fix the bug in this C++ solution
1/*2Given int array & target, return indices of 2 nums that add to target3Ex. nums = [2,7,11,15] & target = 9 -> [0,1], 2 + 7 = 94At each num, calculate complement, if exists in hash map then return5Time: O(n)6Space: O(n)7*/8class Solution {9public:10vector<int> twoSum(vector<int>& nums, int target) {11int n = nums.size();12unordered_map<int, int> mp; // val -> index13for (int i = 1; i < n; i++) {14int complement = target - nums[i];15if (mp.find(complement) != mp.end()) {16return {mp[complement], i};