LeetCode 3464 teaches binary‑search
- YouTube creator codestorywithMIK posted a LeetCode 3464 walkthrough that turns a square-boundary geometry puzzle into a binary-search decision problem. - The video frames the task as “largest feasible distance,” then checks each candidate with ordered boundary points, recursion, and pruning for k up to 25. - LeetCode’s own hints point to binary search and clockwise ordering, making the video a clean interview-pattern explainer. (leetcode.com)
LeetCode 3464 asks for k boundary points on a square whose closest pair is as far apart as possible, and a new codestorywithMIK video explains it with binary search. (youtube.com) (leetcode.com) The raw problem is geometric: every point lies on the square’s border, Manhattan distance measures horizontal-plus-vertical travel, and the input can include as many as 15,000 points. LeetCode caps k at 25, which keeps the selection target small even when the point list is large. (leetcode.com) The video starts with the standard interview move for “maximize the minimum” questions: stop searching directly for the best answer and ask whether a candidate distance d is possible. If distance d works, every smaller distance works too, which creates the monotonic yes-or-no pattern binary search needs. (youtube.com) (leetcode.com) That reframes the problem from geometry into a decision test. Instead of guessing the final arrangement, the algorithm searches a numeric range and repeatedly asks whether it can place k points at least d apart. (youtube.com) (leetcode.com) LeetCode’s hints nudge in the same direction: put boundary coordinates in clockwise order, binary-search the minimum Manhattan distance x, and for each coordinate find the next point at distance at least x. The walkthrough turns those hints into a full method. (leetcode.com) (youtube.com) The key simplification is to treat the square’s perimeter like a single loop instead of four separate sides. Once points are ordered around the border, the search becomes closer to spacing items around a circular track than comparing every pair in two dimensions. (leetcode.com) (walkccc.me) That is why binary search fits. Walkccc’s published solution for 3464 shows the outer search over distances with time complexity O(n log side) and linear extra space, using the ordered boundary points to validate each guess. (walkccc.me) The walkthrough also leans on pruning during feasibility checks, because brute-forcing all k-point subsets would explode combinatorially. With k limited to 25, the practical strategy is to cut branches early once a partial selection cannot beat the candidate distance. (youtube.com) (leetcode.com) That makes the video less about one hard LeetCode prompt and more about a reusable template. When an interview problem asks for the largest X that still works, the first question is often whether X can be checked as a monotonic predicate. (youtube.com) (leetcode.com) For 3464, the square and Manhattan distance supply the geometry, but the lesson is the search pattern. The answer is not found by luck; it is narrowed one feasible distance at a time. (youtube.com)