Skip to content

GfG: Missing in a Sorted Array of Natural Numbers - #1359

Open
paragc05 wants to merge 1 commit into
super30admin:masterfrom
paragc05:master
Open

GfG: Missing in a Sorted Array of Natural Numbers#1359
paragc05 wants to merge 1 commit into
super30admin:masterfrom
paragc05:master

Conversation

@paragc05

@paragc05 paragc05 commented Aug 3, 2026

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Interview Problem: Find Missing Number in a sorted array (Problem12.py)

Strengths:

  1. Your solution correctly implements binary search to find the missing number in O(log n) time.
  2. The code is clean, well-structured, and easy to understand.
  3. Good use of comments to explain the approach.
  4. The edge case handling (when n == 1) is a nice touch.
  5. The variable naming is clear and descriptive.

Areas for improvement:

  1. The example comments in the header are incorrect - they show wrong output values. Make sure to update them to match the actual expected outputs.
  2. Consider adding more edge case handling documentation in comments.
  3. The condition if n == 1: return 1 handles the case when the array is empty (meaning 1 is missing), but you might want to add a comment explaining this edge case.
  4. You could potentially add input validation (e.g., checking if the array is sorted).

VERDICT: PASS


Interview Problem: Design Min Heap

It appears that you have submitted a solution for a different problem (finding a missing integer in a sorted array) instead of the requested Min Heap implementation problem.

To correctly solve this problem, you need to:

  1. Create a class (e.g., MyMinHeap) with an underlying array to store heap elements
  2. Implement helper methods for parent, left child, and right child indices
  3. Implement insert(val) - adds element at end and bubbles up to maintain heap property
  4. Implement getMin() - returns the root element (heap[0])
  5. Implement extractMin() - removes root, replaces with last element, and heapifies down
  6. Implement a heapify() helper method to restore heap property after removal

Please resubmit with a solution that actually implements the Min Heap data structure with the required operations.

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