Reported March 2026
Microsoftgraph

Maximum Data Transfer Time

Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Microsoft OA. Under 2s to a working solution.
Founder's read

The data structure this Microsoft question hinges on is a plain adjacency list. It was reported in March 2026, and it's the tree diameter problem wearing a server-network costume. You get g_nodes servers, g_nodes - 1 edges, and you return the longest path between any two servers, counted in edges. If your OA invite lands this week, expect this shape: build the graph, run a traversal, return a number. It looks easy. The traps are recursion depth with 50,000 nodes and mixing up edges and nodes. StealthCoder sits invisibly as a safety net if you blank mid-assessment, but the idea is short enough to hold in your head.

The problem

A server network is represented as a tree of g_nodes servers numbered from 1 to g_nodes. The network contains g_nodes - 1 edges, where the ith edge connects servers g_from[i] and g_to[i].
Transferring data across one edge takes 1 unit of time. Return the maximum time required to transfer data between any two servers in the network.

Function
getMaxTime(g_nodes: int, g_from: int[], g_to: int[]) → int

Examples
Example 1
g_nodes = 3
g_from = [1,2]
g_to = [2,3]
return = 2
The longest transfer path is from server 1 to server 3. It crosses two edges, so the maximum transfer time is 2.

Constraints
1 ≤ g_nodes ≤ 5 * 10^4
1 ≤ g_from[i], g_to[i] ≤ g_nodes

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is the double BFS. Build an adjacency list from g_from and g_to. Run BFS from any node, say 1, and record the farthest node. Run BFS again from that node. The farthest distance found is the diameter, and that's your answer. The alternative is one DFS that tracks the two deepest child depths at each node and updates a global max of their sum. Both are O(n). The common pitfall is recursion. With g_nodes up to 5 * 10^4, a chain-shaped tree can blow the stack in some languages, so prefer iterative BFS. Also handle g_nodes = 1, where there are no edges and the answer is 0. Return edges, not nodes, so a path of 3 servers gives 2. If you freeze during the live OA, StealthCoder can supply the BFS skeleton while you verify the edge cases.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Maximum Data Transfer Time cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as diameter of n ary tree. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Microsoft's OA.

Microsoft reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Data Transfer Time FAQ

What's the trick to Maximum Data Transfer Time?+

It's the diameter of a tree. BFS from any node to find the farthest node, then BFS again from that node. The max distance in the second pass is the answer. It works because the tree has no cycles, so the farthest node from any start is always an endpoint of a longest path.

How hard is this Microsoft OA question really?+

Easy to medium. The concept is a known classic, but you have to recognize it under a story about servers. If you've seen tree diameter once, it's ten minutes of code. If you haven't, you may try all-pairs distances and time out.

Can I just run BFS from every node?+

No. That's O(n^2) and with g_nodes up to 50,000 it will time out. The double BFS or a single DFS with depth tracking gets you O(n). Don't brute force this one.

Should I use recursion or iteration?+

Iteration is safer. A chain of 50,000 nodes can overflow the call stack in Python or Java with default settings. Use a queue-based BFS with a distance array. If you prefer DFS, use an explicit stack.

What edge cases should I test before submitting?+

Test g_nodes = 1 with empty edge lists, which should return 0. Test a straight line, like the example, returning 2. Test a star shape, where the answer is 2. Also confirm you count edges rather than nodes.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Microsoft.

OA at Microsoft?
Invisible during screen share
Get it