Skip to content

Create Solution.java#2470

Open
YogeshPardeshi wants to merge 1 commit into
super30admin:masterfrom
YogeshPardeshi:patch-1
Open

Create Solution.java#2470
YogeshPardeshi wants to merge 1 commit into
super30admin:masterfrom
YogeshPardeshi:patch-1

Conversation

@YogeshPardeshi
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Create Queue using Stacks (Solution.java)

The student appears to have submitted code for a different LeetCode problem entirely. The submitted solution solves "Find First and Last Position of Element in Sorted Array" using binary search, which has nothing to do with implementing a queue using two stacks.

To improve, the student should:

  1. Carefully read the problem statement before submitting
  2. Implement the MyQueue class with the required methods: push, pop, peek, and empty
  3. Use two stacks (inSt and outSt) to simulate queue operations
  4. For push: append to inSt
  5. For pop/peek: if outSt is empty, transfer all elements from inSt to outSt (reversing order)
  6. For empty: check if both stacks are empty

The reference solution demonstrates the correct approach with amortized O(1) time complexity.

VERDICT: NEEDS_IMPROVEMENT


Implement Hash Map

The student appears to have submitted code for a different problem entirely. To improve:

  1. Read the problem carefully: The problem asks for a HashMap implementation with put, get, and remove methods. The submitted code is for finding target ranges in sorted arrays.

  2. Match the required interface: The class should be named MyHashMap with methods put(int key, int value), get(int key), and remove(int key).

  3. Understand HashMap concepts: A proper solution would use an array of linked lists (chaining) or another collision resolution strategy to implement a hash map from scratch.

  4. If this was a copy-paste error: Please ensure you're submitting the correct solution for the assigned problem.

The student's code itself is well-structured for its intended problem (binary search for range finding), with clear variable naming and proper implementation of the binary search logic. However, it does not solve the HashMap problem at all.

VERDICT: NEEDS_IMPROVEMENT

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