Skip to content

UofT-DSI | algorithms_and_data_structures - Assignment 1#87

Closed
akorade wants to merge 1 commit into
UofT-DSI:mainfrom
akorade:assignment-1
Closed

UofT-DSI | algorithms_and_data_structures - Assignment 1#87
akorade wants to merge 1 commit into
UofT-DSI:mainfrom
akorade:assignment-1

Conversation

@akorade
Copy link
Copy Markdown

@akorade akorade commented Jan 29, 2026

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Implemented solutions for all coding problems in assignment_1.ipynb, including 'first_duplicate', 'is_valid_brackets', and 'move_zeros_to_end', with test cases and printed outputs. Added detailed explanations, complexity analysis, and alternative approaches for the 'first_duplicate' problem. Updated kernel metadata.

What did you learn from the changes you have made?

  • Implemented optimal O(n) time complexity solution using hash set
  • Created 3 additional test cases demonstrating edge cases
  • Provided detailed explanations of algorithm logic and correctness
  • Analyzed time and space complexity with justifications
  • Described alternative brute force approach with trade-off analysis

What did you learn from the changes you have made?

Through this assignment, I learned:

  • Hash sets are powerful for lookup operations: Using a set provides O(1) average-case lookups, which is crucial for achieving optimal O(n) time complexity
  • Space-time trade-offs: The hash set solution uses O(n) space to achieve O(n) time, whereas a nested loop approach uses O(1) space but requires O(n²) time
  • Early termination optimization: Returning immediately upon finding the first duplicate prevents unnecessary iterations
  • Importance of order: Processing elements left-to-right ensures we find the FIRST duplicate (by position of second occurrence)
  • Algorithm analysis: Breaking down complexity into individual operations helps understand overall performance

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

NA

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

NA

How were these changes tested?

NA

A reference to a related issue in your repository (if applicable)

NA

Checklist

  • I can confirm that my changes are working as intended

Implemented solutions for all coding problems in assignment_1.ipynb, including 'first_duplicate', 'is_valid_brackets', and 'move_zeros_to_end', with test cases and printed outputs. Added detailed explanations, complexity analysis, and alternative approaches for the 'first_duplicate' problem. Updated kernel metadata.
@github-actions
Copy link
Copy Markdown

Hello, thank you for your contribution. If you are a participant, please close this pull request and open it in your own forked repository instead of here. Please read the instructions on your onboarding Assignment Submission Guide more carefully. If you are not a participant, please give us up to 72 hours to review your PR. Alternatively, you can reach out to us directly to expedite the review process.

@akorade akorade closed this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant