Assignment 2#2
Open
abeerkhe wants to merge 3 commits into
Open
Conversation
mandana-g
suggested changes
Oct 21, 2025
mandana-g
left a comment
There was a problem hiding this comment.
Thanks Abeer, for Part 1 please consider the following:
- Fix the range to be [0, n-1] or [0, n] depending on interpretation. For example, if the list length is n, and range is [0, n-1], then comparison_set = set(range(len(nums))).
- Return -1 as integer, not a list containing -1.
- Remove unused imports like numpy.
- Use consistent function signature.
Also, consider the following for part 3:
- Review the time complexity, keeping in mind that the if statements are not nested loops and therefore do not compound the time complexity multiplicatively.
Owner
Author
Thanks for the feedback - the updated assignment has been submitted. |
mandana-g
approved these changes
Oct 27, 2025
mandana-g
left a comment
There was a problem hiding this comment.
Thanks Abeer, your assignment 2 is approved.
Just a few notes for your reference:
In Part 3, The “nested if statements” do not add O(n) each, and dictionary membership checks are O(1), not O(n). There is only a single loop over the input of length n, and all operations inside it are constant time. So, the correct time complexity is O(n).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
Answer Question 3 of Assignment 2, review my partner's code (Anna), analyze her code, and provide a reflection of that exercise and Assignment 1.
What did you learn from the changes you have made?
I learned to implement sets to compare expected values in two unordered lists (where output order and duplication is not required), and how to review and analyze somebody else's code.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
I had a few approaches in mind that iterated over the input list in multiple ways (i.e., reordering the list and checking by list index, creating a 'range' from # of duplicate values to check within list for the existence of expected values [instead of iterating the whole list every time], etc.). Instead I opted to use sets as the data structure given the unique requirements of the problem which made it the most effective point of comparison by using the difference (-) operator, reducing time complexity of the problem.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
N/A - biggest challenge was finding the right operation to compare sets.
How were these changes tested?
Running the code and assessing the actual output against expected.
A reference to a related issue in your repository (if applicable)
I accidentally created a pull request to the Main branch in the original UofT repository, instead of to the Main branch for my fork.
Checklist