Twitter Online Assessment (OA) 2021 | University Career Fair

You are an event organizer at a university, and n companies would like to do a presentation about their company at your university on Career Day. However, each company have a tight schedule as to when they can come and present and how long they will present. For the ith company, starting from 0, they can present starting from minute starts[i] and they can present for durations[i] minutes. To give every student a chance to listen to every presentation, the University can allow only one company to present at a time. You would like to host as many presentations as possible, so given each company's schedule, find the maximum number of presentations that the university can hold.


  • starts: A list of integers with size n representing each company's starting time.
  • durations: A list of integers with size n representing the duration of the presentation for each company.


  • The maximum number of presentations that the university can hold.


Example 1:


starts = [1, 3, 3, 5, 7]

durations = [2, 2, 1, 2, 1]

Output: 4

Explanation: Company 0 will present from minute 1~3, either company 1 present from minute 3~5 or company 2 present from minute 3~4. Then. company 3 and 4 can present without conflict. Therefore, a total of 4 companies can present.


  • 1 <= n <= 50
  • 1 <= starts[i] <= 1000
  • 1 <= durations[i] <= 1000

Try it yourself




Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions