-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix bug in hint and add explanations #36
Open
jericahuang
wants to merge
6
commits into
Ada-Developers-Academy:main
Choose a base branch
from
jericahuang:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ec4f9d
typo correction
jericahuang dcd6d4b
fix bugs in the hint, add additional explanations.
jericahuang 2d5467a
missing `
jericahuang e50566a
formatting
jericahuang 788f433
Merge branch 'main' into main
jericahuang f4f0f2e
typo correction
jericahuang 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 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
This file contains 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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -206,15 +206,20 @@ Write the logical steps here. | |||||||
Example Steps for an O(n) solution: | ||||||||
|
||||||||
1. Check for valid input | ||||||||
1. if `k < arr[0]` | ||||||||
1. if `k < arr[0]:` | ||||||||
* `return k` | ||||||||
1. Set `index` to `0` | ||||||||
1. `while index < len(arr) - 1` | ||||||||
2. `k = k - arr[0] - 1` | ||||||||
* `k` will be decremented to represent the number of remaining missing nums. This line accounts for missing nums before `arr[0]`. | ||||||||
4. `while index < len(arr) - 1:` | ||||||||
* `current_missing = arr[index + 1] - arr[index] - 1` | ||||||||
* `if k <= current_missing` | ||||||||
* `current_missing` represents how many missing numbers between `arr[index + 1]` and `arr[index]` | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest accounting for where the 1 is coming from.
Suggested change
|
||||||||
* `if k <= current_missing:` | ||||||||
* We found the original kth missing number. The value is `arr[index] + k`. We return it and exit the loop. | ||||||||
* `return arr[index] + k` | ||||||||
* `k = k - current_missing` | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We mention that k gets decremented above, but I think noting why again here is helpful.
Suggested change
|
||||||||
1. return the last element of the list plus the remaining value of `k`. | ||||||||
* `index = index + 1` | ||||||||
5. return the last element of the list plus the remaining value of `k`. | ||||||||
|
||||||||
### !end-explanation | ||||||||
|
||||||||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest calling out where the 1 is coming from.