Перейти к содержимому

Min Arrows to Burst Balloons | Earliest End Wins | LeetCode 75 #73

Placements

0:00 / 0:00

Min Arrows to Burst Balloons | Earliest End Wins | LeetCode 75 #73

5 просмотров · 7 дней назад
Placements
2 подписчика
5 просмотров · 7 дней назад
Minimum Number of Arrows to Burst Balloons (LeetCode 452) — the greedy interval classic every interviewer loves. One arrow shot vertically bursts every balloon whose x-range contains the shot point. What is the FEWEST arrows needed? The answer: sort by END time, shoot each arrow at the earliest end, skip every balloon it bursts. In this video (Hindi narration, English on screen): The carnival intuition: one arrow, many balloons — why the earliest END picks the shot The EXCHANGE ARGUMENT, made visual: slide any optimal first arrow to the earliest end and nothing escapes Why the shot goes exactly AT the end, not the middle — the sliding-arrow demo with live burst counts The tricky code line: why the overlap test uses STRICTLY greater than arrowX (the touching-endpoint trap [1,2],[2,3] needs just 1 arrow) The comparator lambda (compare a[1] less than b[1]) and why sorting by start is flat-out WRONG (animated counter-example) Full C++ code walkthrough, debugger-style: every line lights up as the visual mutates, with the WHY behind each line 4 classic bugs with test cases: greater-or-equal vs strictly-greater, start-sort, missed arrowX update, arrows = 0 Correctness proof in plain words + O(n log n) time / O(1) space analysis 6 edge cases: single, disjoint, all-overlap, touching chain, nested, negatives Problem: https://leetcode.com/problems/minimum... This is video #73 of the LeetCode 75 series in Hindi — 3D-animated, beginner-friendly, one problem at a time. #LeetCode75 #MinArrows #GreedyAlgorithm #DSAinHindi #CodingInterview #Placements #Cpp #DataStructures #Algorithms