DEV Community

Rishi Raj
Rishi Raj

Posted on

1 1

Scheduling Algorithm

This Python Notebook (https://github.com/rishiraj824/scheduling/blob/master/scheduling.ipynb) demonstrates the scheduling algorithm for a list of activities provided through a CSV. It uses the dynamic programming approach to solve for the most compatible activities.

The above solution works for any given activity board as it takes into account the maximum earnings from those activities.

Step 1.
We first sort all our activities based on their finish times and compare the activities one by one to find the next compatible activity because activities cannot overlap each other.

Step 2.
We use a binary search to find the most compatible activity. This takes us O(lg n) time.

Step 3.
We do this n times and while we do this we save the activity names to output all the possible activities in the end.

Step 4.
Keep adding the reward of all the compatible, highest rewards and display the sum in the end.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay