The TransCompilator

Solved LeetCode program · 979 of 1,000

#1353 · Maximum Number of Events That Can Be Attended

Medium Array chunk-20.md

Original English source

Keep a shared starts holding 1, 2, and 3. Keep a shared finishes holding 2, 3, and 4. Keep a shared order holding 0, 1, and 2. Keep a shared best of 0. Keep a shared marks as an empty list of whole numbers.
For every day from 0 to 5.
Place 0 into marks.

Keep a shared answer of 0.

To choose from start (a whole number). Set best to start.
For every which from start to the last position of order.
The candidate is item which of order. The pick is best. The current is item pick of order. If item candidate of finishes is less than item current of finishes, set best to which. If item candidate of finishes is item current of finishes and item candidate of starts is less than item current of starts, set best to which.

For every place from 0 to the last position of order.
Choose from place. swap item place of order and item best of order.

For every rank from 0 to the last position of order.
The event is item rank of order. The begin is item event of starts. The end is item event of finishes.
For every day from begin to end.
If item day of marks is 0.
Set item day of marks to 1. Add 1 to answer. stop.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

3