Search⌘ K

Feature #5: Update VLAN ID

Explore how to update VLAN IDs in a network of interconnected switches arranged in a grid. Learn to implement a Depth-First Search (DFS) to propagate VLAN ID change requests efficiently under given constraints. This lesson helps you understand traversing and updating 2D network arrays, preparing you to solve similar coding interview problems.

Description

We have a network topology in which several network switches are interconnected in a rectangular grid fashion. The switches are configured with VLAN IDs that are stored in a 2D array. Periodically, VLAN IDs need to be changed. At a specific switch, we will initiate a VLAN ID change request. This request will be propagated to its neighbors with the same VLAN ID, which will then forward it to their neighbors, and so on, until all switches in the topology are covered. The security is configured so that a switch will accept a VLAN ID change request only if the request is sent from a switch with the same VLAN ID and is above, below, to its right or left, or in the array. A VLAN ID change request is started at a switch in row r and column c, with a new VLAN ID specified. All the switches’ VLAN IDs need to be updated under the given constraints.

We’ll be provided with a 2D matrix ...