boolcomp(vector<int>a,vector<int>b){// if both of them have no element then return trueif(a.size()==0||b.size()==0)returntrue;// if they have different size then return falseif(a.size()!=b.size())returnfalse;intsize=a.size();// or b.size() as both of them have same sizeunordered_map<int,int>squareCount;// squares a number of a, increment squareCount[squareNumber_a] by 1 i.e. squareCount[squareNumber_a]++// decrement sqareCount[squareNumber_b] by 1 i.e. squareCount[squareNumber_b]--for(inti=0;i<size;i++){squareCount[a[i]*a[i]]++;squareCount[b[i]]--;}// if they are "same" then all the values of corresponding// keys of sqaureCount will be zero// if any one of them is not zero then return falsefor(autoit:squareCount){if(it.second!=0)returnfalse;}returntrue;}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C++ solution