We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
i need explanation
int pickingNumbers(vector a) {
map mp;
for(int e : a) mp[e]++;
int ans = mp[0];
for(int i = 1; i < 99; i++){
int curr = max(mp[i] + mp[i+1], mp[i] + mp[i-1]);
ans = max(ans, curr);
}
return ans;
If you're ever in need of emergency roofing services, it's important to act quickly to prevent further damage and ensure safety.
If you're ever in need of emergency roofing services, it's important to act quickly to prevent further damage and ensure safety.
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
i need explanation int pickingNumbers(vector a) { map mp; for(int e : a) mp[e]++; int ans = mp[0]; for(int i = 1; i < 99; i++){ int curr = max(mp[i] + mp[i+1], mp[i] + mp[i-1]); ans = max(ans, curr); } return ans; If you're ever in need of emergency roofing services, it's important to act quickly to prevent further damage and ensure safety.
}