Embercode
✕
Greedy AlgorithmsCoding problems

Greedy Algorithms: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • A single meeting room is shared by many teams. Each request asks for the room from a start time to an end time. Two meetings may not overlap, but one may start at the exact moment another ends.

    Print the largest number of meetings the room can host.

    Input. The first line has `n` (1 to 20000). Each of the next `n` lines has two integers `start` and `end` (0 <= start < end <= 10^9).

    Output. One integer: the largest number of meetings that do not overlap.

    Example 1 input

    11
    1 4
    3 5
    0 6
    5 7
    3 9
    5 9
    6 10
    8 11
    8 12
    2 14
    12 16
    

    Output

    4
    

    Example 2 input

    3
    1 3
    2 4
    3 5
    

    Output

    2