Line 1034: Char 34: runtime error: applying non-zero offset 24 to null pointer (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34
class Solution { public: int numIdenticalPairs(vector& nums) {
int pair_count=0;
vector<vector<int>> v;
for(int i=0;i<nums.size();i++)
{
v[nums[i]].push_back(i);
}
for(int i=1;i<v.size();i++)
{
int size=v[i].size();
pair_count+=floor(size/2);
}
return pair_count;
}
};
Aucun commentaire:
Enregistrer un commentaire