Sensor Grid Anomaly Detection
Sensor Grid Anomaly Detection
A smart farming operation in Punjab uses a 2D sensor grid to monitor soil moisture. An anomaly region is defined as a rectangular area where the difference between max and min values exceeds a threshold T. Find all such regions and their anomaly score (max - min). Rule: count ALL axis-aligned subrectangles (any size >= 1x1) where max-min > T. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.
Approach
Given an M×N grid of sensor readings, find all subarrays where (max - min) > T and return count of such subarrays with their maximum difference.
Input
Output
More Arrays problems
Browse all coding problems →Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards