Skip to content

completed comp-coding-01#1358

Open
angad-singh97 wants to merge 1 commit into
super30admin:masterfrom
angad-singh97:master
Open

completed comp-coding-01#1358
angad-singh97 wants to merge 1 commit into
super30admin:masterfrom
angad-singh97:master

Conversation

@angad-singh97

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Interview Problem: Find Missing Number in a sorted array (01-missing-num-in-sorted-array.cpp)

Strengths:

  • Excellent understanding of binary search application to this problem
  • Well-documented code with clear explanation of the algorithm's intuition
  • Proper handling of edge cases (using hi instead of lo for final calculation)
  • Good variable naming and code structure

Areas for Improvement:

  • The solution solves a more general problem (k-th missing) than the reference (single missing), which is actually a strength, but ensure alignment with specific problem requirements
  • Consider adding validation for empty arrays or invalid inputs
  • The comment about "leaving room for k missing numbers" could be more precise

Technical Note:
The solution correctly handles the case where all elements are consecutive by returning nums[n-1] + k. However, the reference solution's simpler approach for finding a single missing number is more straightforward for the specific problem stated.

VERDICT: PASS


Interview Problem: Design Min Heap (02-implement-min-heap.cpp)

Strengths:

  1. Clean, well-commented code with good variable names
  2. Correct implementation of core heap operations (push/pop/heapify)
  3. Proper handling of edge cases (empty heap returns -1)
  4. Good understanding of percolate-up and sift-down operations
  5. Heapify uses Floyd's algorithm correctly - O(n) vs O(n log n) for repeated inserts
  6. Good use of vector for dynamic storage

Areas for Improvement:

  1. Missing getMin(): The problem explicitly requires this O(1) operation to return the root element
  2. No main() function or test case: Reference solution includes a working example
  3. Constructor could be simplified: Using initializer list would be more idiomatic C++
  4. Consider adding capacity management: The reference solution has a maxSize limit; your vector grows dynamically which is fine but could be a discussion point
  5. Add print functionality: For debugging and verification purposes

Code Style Notes:

  • The comments about C++ syntax show good self-awareness about learning
  • Consider using explicit for single-parameter constructors
  • The destructor is unnecessary since vector handles cleanup automatically

Overall, this is a solid implementation that demonstrates good understanding of heap data structures.

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