Home > Back-end > C to return to an empty curly braces {} represents what mean
C to return to an empty curly braces {} represents what mean
Time:09-27
The class Solution { Public: Vector MaxSlidingWindow (vector & Nums, int k) { Int n=nums. The size (); If (n * k==0) { Return {}; } Vector Res. for(int i=0; iInt max_num=INT_MIN; For (int j=I; JMax_num=Max (nums [j], max_num); } Res. The push_back (max_num); } return res; } };
CodePudding user response:
The return type is vector
Return {}; It is to return empty, but is null or empty vector is not clear, can verify
CodePudding user response:
Is a vector , the size is zero; NULL cannot be vector Object; This is equivalent to construct a temporary object is used to return
CodePudding user response:
C + + new syntax, their search 11/14 new features in c + +, make up a missed lesson can seriously,
CodePudding user response:
An empty vector
CodePudding user response:
Returns an empty vector
CodePudding user response:
That is to say, when you don't meet the if condition, there is no right as a result, this time don't need to double down the for loop, the program can end, but the function return value Vector< again; Int> (that is, the function name in front of the type), and then back {} to represent no results, returns an empty vector , like a house, the house is still there, but nothing inside, in order to facilitate understanding, if you want to return to a specific value vector And then the return value can be written as the return {1, 2, 3, 4}, this means return vector Contains 1, 2, 3, 4 these a few elements, equivalent to use these elements to create a vector< containing 1, 2, 3, 4; Int>