FastPrepLatest Top 100 News Stories

Latest Top 100 News Stories

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN
Learn

Problem statement

storyIds[i] identifies a unique story whose latest history timestamp is updatedAt[i]. Return up to 100 IDs ordered by descending timestamp, breaking ties by lexicographically smaller ID.

Function

latestStories(storyIds: String[], updatedAt: long[]) → String[]

Examples

Example 1

storyIds = ["b","a","c"]updatedAt = [5,5,7]return = ["c","a","b"]

c is newest; a and b tie and sort by ID.

Constraints

  • Arrays have equal length.
  • IDs are unique.
  • At most 10^5 stories.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public String[] latestStories(String[] storyIds, long[] updatedAt) {
  // Write your code here.
}
storyIds["b","a","c"]
updatedAt[5,5,7]
expected["c", "a", "b"]
Checking account…