Back to articles
Maximum Points Activated with One Addition - LeetCode Solution

Maximum Points Activated with One Addition - LeetCode Solution

via Dev.to PythonBigO Lab

Today we're looking at a hard problem from a recent LeetCode contest: Maximum Points Activated with One Addition . It looks intimidating at first, but once you map out how the points interact with each other, it boils down to a classic graph problem. Let's break it down. The Problem Problem link We're given an array of points on a 2D plane. If you activate a point, every other point that shares its exact X or Y coordinate also gets activated — creating a chain reaction until nothing new can trigger. We're allowed to add exactly one new point at any empty integer coordinate. Place it to maximize the total number of activated points. Example: Input : points = [[ 1 , 1 ],[ 2 , 2 ],[ 3 , 1 ]] Points [1,1] and [3,1] share y = 1 , so they're in the same component. [2,2] is isolated. Add a point at [2,1] → bridges both components → all 4 points activate. Intuition: Think in Graphs When a problem says "if A connects to B, and B connects to C, they all trigger together" — that's a connected com

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles