There's something about & usage that confuse me it has
vector<int> nums
vector<int>& nums
vector<int> &nums
I am not sure about the difference between them.
class Solution {
public:
int maxArea(vector<int>& height) {
long i = 0;
int j = (height.size() - 1);
long water = 0;
while (i < j) {
water = max(water, ((j - i) * min(height[i], height[j])));
if (height[i] < height[j]) {
i += 1;
} else {
j -= 1;
}
}
return water;
}
};
above answer pass with or without the & in LeetCode, why should we need to care about &