error:control reaches end of non-void function [-Werror=return-type]

What are the eight life cycle hook functions of Vue>>>

This error occurred when doing the topic on leetcode

The original code is as follows:

 1 class Solution {
 2 public:
 3     vector<int> twoSum(vector<int>& nums, int target) {
 4         vector<int> v;
 5         unordered_map<int, int> m; 
 6         for(int i=0;i<nums.size();++i)
 7         {
 8             int tt=target-nums[i];
 9             if(m.find(tt)!=m.end())
10             {
11                  v.push_back(m[tt]);
12                 v.push_back(i);
13                 return v;
14             }  
15             else
16                     m[nums[i]]=i;
17         }
18         //return v;
19     }
20 };

You can see that 18 lines have been commented out by me. It is the missing line that causes the program to not return the value

Similar Posts: