When nums.size() = 0, because the type of nums.size() is size_t, which is the typedef of unsigned long long, it can only be a positive number, so when nums.size() -1, nums.size() is 0, the answer is expressed in binary, is 2^64 - 1, a huge positive number, so WA. It is recommended not to write nums.size() inside for, as nums.size() will be called every time, which increases overhead. . .
When
nums.size() = 0
, because the type ofnums.size()
issize_t
, which is the typedef ofunsigned long long
, it can only be a positive number, so whennums.size() -1
,nums.size()
is 0, the answer is expressed in binary, is 2^64 - 1, a huge positive number, so WA. It is recommended not to writenums.size()
inside for, asnums.size()
will be called every time, which increases overhead. . .