Number of Provinces
Asked at Expedia · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026
Given an `n x n` matrix representing connectivity between `n` cities. If city `i` is directly connected to city `j`, `matrix[i][j] = 1`. If city `i` is not directly connected to city `j`, `matrix[i][j] = 0`. Return the number of connected components (i.e., number of provinces).
Loading the problem…
More Expedia interview questions
- Implement a Basic Tokenizer and Train a Simple LLM-like Model in a Notebook Case Study
- Minimum Additional Capabilities to Equalize Team Work Hours
- Get Maximum Efficiency
- Get Minimum Steps
- Scattered Palindrome Substring Count (Swappable to Palindrome)
- Dynamic Programming (Medium) Similar to House Robber