Skip to content

Submit Design-1 PR - #2689

Open
agk-s30 wants to merge 2 commits into
super30admin:masterfrom
agk-s30:master
Open

Submit Design-1 PR#2689
agk-s30 wants to merge 2 commits into
super30admin:masterfrom
agk-s30:master

Conversation

@agk-s30

@agk-s30 agk-s30 commented Jul 30, 2026

Copy link
Copy Markdown

No description provided.

agk-s30 added 2 commits July 30, 2026 01:21
Implement MinStack class with push, pop, top, and getMin methods.
Implement a MyHashSet class with add, remove, and contains methods using double hashing.
@super30admin

Copy link
Copy Markdown
Owner

Design HashSet (Exercise_1.py)

Strengths:

  • Excellent translation of the algorithm to Python with proper type hints
  • Smart choice of secondary_buckets = 1001 to avoid the special case handling for primary_index == 0
  • Clean, readable code with helpful comments
  • All edge cases are properly handled

Areas for improvement:

  • Consider using self.secondary_buckets in _secondary_hash for clarity, or rename the method to make it clear that it's computing the index based on primary bucket size
  • The comment "works well here because this is a set" could be more concise
  • You could add a brief explanation of why secondary_buckets = 1001 (to accommodate key = 10^6 mapping to index 1000)

Overall, this is a high-quality solution that demonstrates a clear understanding of the double hashing technique and properly handles all edge cases.

VERDICT: PASS


Min Stack (Exercise_2.py)

Your solution is excellent! It correctly implements the Min Stack with O(1) time complexity for all operations. Here are some strengths and minor suggestions:

Strengths:

  1. Correct handling of duplicates: Using value <= self.min_stack[-1] in push and equality check in pop correctly handles duplicate minimum values.
  2. Space optimization: By only pushing to min_stack when the value is a new minimum (or equal), you save space compared to pushing on every operation.
  3. Clean code: Well-structured with appropriate type hints and clear method names.
  4. Good documentation: The header comments explain the approach clearly.

Minor suggestions:

  1. Edge case documentation: You could add a brief comment explaining why <= is used (to handle duplicate minimums).
  2. Method naming: Python convention typically uses snake_case for method names (e.g., push, pop, top, get_min) rather than camelCase. However, since this matches the problem description, it's acceptable.
  3. Consider adding docstrings: Adding docstrings to each method would improve readability and provide documentation.

Overall, this is a high-quality solution that demonstrates a solid understanding of the problem and efficient implementation.

VERDICT: PASS

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.

2 participants