public List<Integer> getNewsFeed(int userId) {
            List<Integer> res = new ArrayList<>();
            if (!graph.containsKey(userId)) return res;

            PriorityQueue<Tweet> q = new PriorityQueue<Tweet>((t1, t2) -> t2.time - t1.time);
            if (tweets.containsKey(userId)) q.offer(tweets.get(userId));
            for (int fid : graph.get(userId)) {
                if (tweets.containsKey(fid)) q.offer(tweets.get(fid));
            }
            while (!q.isEmpty() && res.size() < 10) {
                Tweet t = q.poll();
                if (t.next != null) q.offer(t.next);
                res.add(t.id);
            }
            return res;
        }