Dsa
Graphs Dfs
Medium
Air Quality Monitoring
You have a grid representing a city’s air quality where each cell has a value between 0 (poor) and 100 (great). A component of air quality is defined as a group of adjacent cells (horizontally/vertically) with an average quality value above a threshold. Write a program to determine the number of components that exceed the average quality threshold.
Input Format:
- The first line contains two integers R and C, the number of rows and columns.
- The next R lines contain C integers each.
- The last line contains a threshold value.
Output Format:
- Print the number of components exceeding the average quality threshold.
Example:
Input:
3 3
60 80 75
90 40 50
70 85 100
70
Output:
3
Key concepts
graphsdfsconnected components
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now