경쟁 프로그래밍쉬움

활동 선택

'활동 선택' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

활동의 시작 및 종료 시간을 나타내는 두 개의 목록 startend을 사용하는 activity_selection(start, end) 함수를 작성하세요. 한 사람이 한 번에 하나의 활동만 할 수 있다고 가정하고, 한 사람이 수행할 수 있는 최대 활동 수를 구하십시오. 두 번째 활동의 시작 시간이 첫 번째 활동의 종료 시간보다 크거나 같은 경우 두 활동은 겹치지 않습니다.

제약
  • 1 <= len(start) == len(end) <= 10^5
  • 0 <= start[i] < end[i] <= 10^9

Example 1
Input
activity_selection([1, 3, 0, 5, 8, 5], [2, 4, 6, 7, 9, 9])
Output
4
Explanation

A person can perform at most 4 activities: [1,2], [3,4], [5,7], and [8,9].

Example 2
Input
activity_selection([10, 12, 20], [20, 25, 30])
Output
2
Explanation

Two activities can be performed: [10,20] and [20,30].

Need a Hint?
세트나 힙과 같은 Greedy 관련 데이터 구조를 사용하는 것을 고려해보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.