Solution - Implement Queue using only 2 stacks - #2497
Conversation
Implement Queue using Stacks (MyHashMap.java)It appears you have submitted a solution for a different problem (Design HashMap) instead of the problem that was asked (Implement Queue using Stacks). To correctly solve "Implement Queue using Stacks," you need to:
The key insight is that pushing elements onto one stack and then transferring them to another stack reverses their order, which is exactly what you need to convert LIFO (stack) into FIFO (queue). Please re-submit your solution for the correct problem. VERDICT: NEEDS_IMPROVEMENT Design HashMap (Sample.java)It looks like you've submitted a solution for "Implement Queue using Stacks" (LeetCode 232) instead of "Design HashMap" (LeetCode 706). These are two completely different problems. For the Design HashMap problem, you need to:
A common approach is to use an array of buckets where each bucket is a linked list (separate chaining) to handle collisions. The hash function typically uses modulo operation on the key. Please resubmit with the correct solution for the Design HashMap problem. VERDICT: NEEDS_IMPROVEMENT |
Solution - Implement Queue using only 2 stacks