Skip to the code
cf.
+10 XP

#577 Most Talks One Person Can Attend

easy

A conference app builds a personal schedule. Each talk is [start, end] in minutes from the start of the day. A person can be in only one talk at a time, and must stay from its start to its end. A talk may start at the exact minute another one ends.

Write mostTalks(talks) that returns the largest number of talks one person can attend.

Example 1

Input: talks = [[1,3],[2,5],[0,4],[4,6],[3,8],[5,7],[6,9],[8,10]]
Output: 3

For example [1, 3], [4, 6], and [6, 9].

Example 2

Input: talks = [[0,40],[10,15],[20,25]]
Output: 2

Skip the long talk and attend the two short ones.

Constraints

  • 0 <= talks.length <= 100000
  • 0 <= start < end <= 10^9
Saved in this browser

Run 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).