Maximum Strength of Every Neuron
Learn this problemProblem statement
You are given a tree-shaped network of n neurons with n - 1 undirected connections. Connection i joins neurons neuronFrom[i] and neuronTo[i]; neuron labels are 1-based.
Each neuron is either strong or weak:
strongConnectivity[i] = 1means neuroni + 1is strong and contributes+1.strongConnectivity[i] = 0means neuroni + 1is weak and contributes-1.
The score of a connected subnetwork is the number of strong neurons in it minus the number of weak neurons in it.
Return an array neuronStrengths of length n, where neuronStrengths[i] is the maximum score among all connected subnetworks that contain neuron i + 1.
What the interview report shared
The report gave the tree model, complete scoring rule, and one concrete example. This practice version is an estimated 95% match to that core task; the report did not include numeric limits, so none are added here.
Function
maximumNeuronStrength(n: int, neuronFrom: int[], neuronTo: int[], strongConnectivity: int[]) → int[]Examples
Example 1
n = 4neuronFrom = [1,1,1]neuronTo = [2,3,4]strongConnectivity = [0,0,1,0]return = [0,-1,1,-1]Neuron 3 is strong, so the best connected subnetwork containing it has score 1. Neuron 1 can include neuron 3 for score 0. For either weak leaf, adding the center and the strong neuron still gives score -1, so its best strength is -1.
More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026
- Escape Game - Maximize ScoreOA · Seen Jul 2026