๐Ÿ“…

Scheduler

Sort events by start time, detect clashes and find free slots in a day.

Project 9Advanced

๐Ÿงฉ Problem statement

Events are “NAME:START:END” with whole hours (9 to 17). Show the events sorted by start time as “START-END NAME”, then every clash as “Clash: A and B” (two events clash if they overlap), then the free hours between 9 and 17.

๐Ÿ“‹ Requirements

  • Events
  • Dates & times (hours)
  • Conflicts
  • Availability
  • Sorting

๐Ÿ“ฅ Inputs

  • EVENTS: list of "name:start:end"

๐Ÿ“ค Outputs

  • Sorted schedule
  • Clashes
  • Free hours

๐Ÿ“ Rules

  • Events overlap if A.start < B.end and B.start < A.end
  • The working day is 9โ€“17

๐Ÿšง Constraints

  • Up to ~50 events

๐Ÿงญ Suggested approach

  • Parse into records
  • Sort by start (insertion sort)
  • Compare every pair for overlap
  • Mark busy hours in a list of 24 flags

๐Ÿง  Required concepts

  • Records
  • Sorting
  • Nested loops
  • Lists
โœ๏ธ Pseudocode editor ยท dry-run tool ยท test cases

Design your solution here. Use Run to dry-run it step by step and Run tests to check it. Hints unlock one at a time โ€” try on your own first!

๐Ÿงช Edge cases to test

  • Events that touch but donโ€™t overlap (10โ€“11 and 11โ€“12)
  • A fully booked day
  • No events

๐Ÿ“ˆ Complexity analysis

Parsing O(n), insertion sort O(nยฒ), clash check O(nยฒ), free hours O(8n).

๐Ÿ“– Solution walkthrough (open after youโ€™ve tried!)

Each event is parsed into a record, then insertion sort orders them by start time. Every pair is checked with the standard overlap test โ€” note that 10โ€“11 and 11โ€“12 do NOT overlap, because one ends exactly when the other starts. Finally each working hour is checked against all events to list the free hours.

๐Ÿš€ Challenge extensions

  • Support minutes ("9:30")
  • Suggest the first free slot of a given length
  • Handle several days

โ† All projects