A notifications page merges activity from several services. Each service sends its event timestamps already sorted from oldest to newest.
Write mergeFeeds(feeds) that returns all timestamps from all feeds in one array sorted ascending. Some feeds may be empty, and feeds itself may be empty. Aim for O(N log k) time for N timestamps in k feeds.
Input: feeds = [[1,4,9],[2,3,10],[5]] Output: [1,2,3,4,5,9,10]
Always take the smallest front timestamp among the feeds.
Input: feeds = [[],[7],[]] Output: [7]
Empty feeds add nothing.
0 <= k <= 5000 <= feeds[i].length <= 500Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #388 Merge Sorted Activity Feeds. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.