Conversation
Implement Hash Set (Sample.java)Your solution is generally correct and follows the separate chaining approach. Well done on preventing duplicate keys in the add method. However, there are a few areas for improvement:
Overall, your solution is functional and passes the basic test cases. With minor improvements, it can be more efficient and cleaner. VERDICT: PASS Implement Min StackIt seems there might be a misunderstanding. The problem you were asked to solve is to design a MinStack, but your solution is for a MyHashSet (a hash set). This indicates that you might have confused the problem with another one. For the MinStack problem, you need to design a stack that can push, pop, and return the top element in constant time, as well as return the minimum element in constant time. The common approach is to use two stacks: one to store all the elements and another to store the minimum values. Alternatively, you can use a single stack that stores pairs (value, current_min). I recommend revisiting the problem statement and understanding the requirements. The example input and output should help clarify what is expected. Your current solution for MyHashSet is well-structured for that problem, but it does not apply here. For the MinStack, you should start from scratch. Strengths:
Areas for improvement:
VERDICT: NEEDS_IMPROVEMENT |
No description provided.