Skip to content

Instantly share code, notes, and snippets.

@akshar702
akshar702 / gist:c9d08c698f6a47714811b353b383756d
Created April 17, 2026 10:21
camera-coverage-updated.ts
/**
* Approach: 2D Rectangle Coverage using Coordinate Compression
*
* 1. Collect all unique distance boundary points from target + cameras
* 2. For each distance slice between consecutive boundaries:
* - Find cameras covering that entire slice
* - Check if those cameras fully cover the light range (1D problem)
* 3. If any slice fails light coverage → insufficient
*
* IMPROVED: Added input validation and invalid camera filtering
/**
* Approach: 2D Rectangle Coverage using Coordinate Compression
*
* 1. Collect all unique distance boundary points from target + cameras
* 2. For each distance slice between consecutive boundaries:
* - Find cameras covering that entire slice
* - Check if those cameras fully cover the light range (1D problem)
* 3. If any slice fails light coverage → insufficient
*/