Answers for "count map c++"

C++
1

map count function c++

map_name.count(key k)
/*
   Parameters: k which specifies the key to be searched in the map container.
   Return Value: returns the number of times the key K is present in the map container. 
   		  "RETURNS 0"- if the key is not present in the map container.
*/
Posted by: Guest on July-16-2021
0

what does map.count() return in c++

int n; cin>>n;
long val;
map<int,long> mp3;
long long res=0;
while(n--){
	cin>>val;
	if(mp3.count(val)) 	res+=mp3[val]; 
    //mp3.count(val) returns 1 if val is present in the map already or 
    //the number of times the key K is present in the map container.
    if(mp2.count(val)) 	mp3[val*r]+=mp2[val];
	mp2[val*r]++;
}
cout<<res<<endl;
Posted by: Guest on June-08-2020

Browse Popular Code Answers by Language