Time: 0:00
Test a custom input to verify an edge case (e.g. empty lists, negative numbers, duplicates).
This bug belongs to the logic errors pattern
The wrong operator, an inverted condition, a formula the right way round but backwards.
What went wrong: Memory allocated using new T[] must strictly be released using delete[] buffer. Using scalar delete invokes undefined behavior and heap corruption.
The fix: Use delete[] buffer to deallocate array memory.
Remember: Always pair new with delete, and new[] with delete[]. Prefer std::vector or std::unique_ptr<T[]> over raw pointers.
The pattern behind it: logic errors.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/528a4322-7141-41f6-9365-8b5c2d2c2474" title="Debugging challenge: delete vs delete[] mismatch on dynamic array" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/528a4322-7141-41f6-9365-8b5c2d2c2474">TryBugHunt</a></p>