Daily challenge for 2026-09-22
630. Server Topology Bottleneck Score
You are monitoring a network of n computer servers labeled from 0 to n - 1. You are given an integer n and a 2D array of directed connections routes, where each routes[i] = [u, v] indicates that server u sends traffic directly to server v.
A server's bottleneck score is defined as the number of incoming traffic routes minus the number of outgoing traffic routes. Return an array of length n where the i-th element is the bottleneck score of server i.
Example:Input: n = 4, routes = [[0, 1], [0, 2], [1, 2], [2, 3]]Output: [-2, 0, 1, 1]
Explanation: Server 0 has in-degree 0 and out-degree 2 (score: -2). Server 1 has in-degree 1 and out-degree 1 (score: 0). Server 2 has in-degree 2 and out-degree 1 (score: 1). Server 3 has in-degree 1 and out-degree 0 (score: 1).