3
map<int, priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>> user;4
map<int, set<int>> connect;8
void postTweet(int userId, int tweetId) {9
user[userId].push({time, tweetId}); // stores as (time,tweet) pair to min heap11
if (user[userId].size() > 10) // keeping max 10 recents post of a user14
void fun(priority_queue<pair<int, int>> &pq,15
int id) // add elements from min heap(id) to max heap(pq)17
vector<vector<int>> temp;18
while (!user[id].empty()) {19
int a = user[id].top().first;20
int b = user[id].top().second;23
temp.push_back({a, b});26
user[id].push({x[0], x[1]});29
vector<int> getNewsFeed(int userId) {31
priority_queue<pair<int, int>> pq;32
fun(pq, userId); // user itself33
for (auto x : connect[userId]) // posts by followers39
v.push_back(pq.top().second);47
void follow(int followerId, int followeeId) {48
connect[followerId].insert(followeeId);51
void unfollow(int followerId, int followeeId) {52
connect[followerId].erase(followeeId);