-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Create ActivitySelection #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Create ActivitySelection #1384
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7a043be
Create ActivitySelection
swatiprajapati08 7a62cb1
Update and rename ActivitySelection to activity_selection.py
swatiprajapati08 6c3ac74
Update activity_selection.py
swatiprajapati08 fabebff
Update activity_selection.py
swatiprajapati08 b932461
Update activity_selection.py
swatiprajapati08 25be089
Update activity_selection.py
swatiprajapati08 cd1155c
Update activity_selection.py
swatiprajapati08 aa0fe80
Update activity_selection.py
swatiprajapati08 e5688b3
Rename activity_selection.py to other/activity_selection.py
swatiprajapati08 d8af953
Update activity_selection.py
swatiprajapati08 eda9ed8
Update activity_selection.py
swatiprajapati08 32d9d39
Add a doctest
cclauss 6222c04
print(j, end=" ")
cclauss 2def0bc
print(i, end=" ")
cclauss 4dfd359
colons
cclauss 8d7a6b7
Add trailing space
cclauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""The following implementation assumes that the activities | ||
are already sorted according to their finish time""" | ||
|
||
"""Prints a maximum set of activities that can be done by a | ||
single person, one at a time""" | ||
# n --> Total number of activities | ||
# s[]--> An array that contains start time of all activities | ||
# f[] --> An array that contains finish time of all activities | ||
|
||
def printMaxActivities(s, f ): | ||
n = len(f) | ||
print("The following activities are selected") | ||
|
||
# The first activity is always selected | ||
i = 0 | ||
print(i) | ||
|
||
# Consider rest of the activities | ||
for j in range(n): | ||
|
||
# If this activity has start time greater than | ||
# or equal to the finish time of previously | ||
# selected activity, then select it | ||
if s[j] >= f[i]: | ||
print(j) | ||
i = j | ||
|
||
# Driver program to test above function | ||
s = [1, 3, 0, 5, 8, 5] | ||
f = [2, 4, 6, 7, 9, 9] | ||
printMaxActivities(s, f) | ||
|
||
|
||
|
||
|
||
|
||
"""The following activities are selected | ||
0 1 3 4""" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.