Bob has a startup that is developing a product that uses “advanced AI” and “black magic” to automatically code-golf computer programs. Unfortunately, Bob is running out of cash and desperately needs money from investors to keep his company running. Each investor that Bob has contacted wishes to schedule a meeting with a certain start and end time. However, some of meeting times conflict with each other. Bob wishes to meet with as many investors as possible so he can raise the largest amount of money. How many investors can Bob meet with, given that Bob can only meet with one investor at a time?
Input is given as an array of pairs (or the equivalent in your chosen language). Each pair p represents one investor, where
p is the start time of the investor’s meeting and
p is the end time.
For example, in the test case
[(0,10),(5,10),(12,13)], there are three investors: one who wants to meet from time 0 to time 10, one who wants to meet from time 5 to time 10, and one who wants to meet from time 12 to time 13. Meetings will always have a positive duration, and a meeting that ends at time
k does not conflict with a meeting that starts at time
You may use any reasonable I/O method for input.
[(0,10),(5,10),(12,13)] => 2 (investors 1 and 3) [(10,20),(10,20),(20,30),(15,25)] => 2 (investors 1 and 3) [(0,3),(1,5),(1,5),(1,5),(4,9),(6,12),(10,15),(13,18),(13,18),(13,18),(17,19)] => 4 (investors 1,5,7 and 11) [(1,1000),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7)] => 6 (every investor except the first) [(1,2),(101,132),(102,165),(3,9),(10,20),(21,23),(84,87)] => 6 (investors 1,2,4,5,6,7)
Your program should output an integer, the maximum number of investors that Bob can meet with.
Standard loopholes are prohibited. This is code-golf, so the shortest solution in each language wins.