Most Visited String Sectors
Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Microsoft reported this one in September 2026, and the trap is hiding in the wrap-around. Most Visited String Sectors looks like a string problem, but it's really index math on a circular track. A naive solution walks every step of every leg, and that works until rounds hits 10^5 entries. The other classic miss is double-counting the sector where one leg ends and the next begins. If you've got this OA coming, know the trick before you open the editor. StealthCoder sits invisibly as a safety net on the live assessment if your mind goes blank mid-problem.
The problem
A circular track is divided into distinct sectors whose string labels are given in clockwise order by sectors. A runner starts in rounds[0]. For each later label in rounds, the runner moves clockwise until reaching that sector. Count the starting sector once and count each sector whenever the runner enters it. Return every sector with the maximum visit count, preserving the clockwise order in sectors. Function mostVisitedSectors(sectors: String[], rounds: String[]) → String[] Examples Example 1 sectors = ["north","east","south","west"] rounds = ["north","south","north","east"] return = ["north","east"] North and east are each visited twice, while south and west are each visited once. Example 2 sectors = ["red","blue","green"] rounds = ["green","blue"] return = ["red","blue","green"] The clockwise trip from green to blue visits green, red, and blue once, so every sector ties. Constraints 2 <= sectors.length <= 100 2 <= rounds.length <= 10^5 All sector labels are distinct, nonempty strings. Every label in rounds appears in sectors.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Map each label to its index in sectors with a hash map. Then treat each leg as a walk from index a to index b clockwise. Count the start sector once, then count every sector you enter. The edge case is when b is less than a, because the walk wraps past the end of the array. Also watch for a leg where a equals b: the runner doesn't move, so you add nothing. Sectors is at most 100, so simulating each leg costs up to 100 steps, giving about 10^7 operations at worst. That's fine. A difference array is the faster option, but it's not needed. The pitfall is counting the junction sector twice, so only increment on entry. Finally, collect every sector tied for the max, in the original sectors order. If you freeze on the wrap logic, StealthCoder is the hedge on the live OA.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Most Visited String Sectors 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 by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as most visited sector in a circular track. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Microsoft's OA.
Microsoft reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Most Visited String Sectors FAQ
What's the trick in Most Visited String Sectors?+
Convert labels to indices with a hash map, then walk clockwise using modulo arithmetic. Count the start once and each entered sector once. The wrap-around from a high index back to a low one is where naive code breaks.
How hard is this Microsoft OA question really?+
Easy to medium. The logic is short, but the edge cases catch people: legs that wrap, legs that don't move, and the junction sector counted twice. If you handle those, it's a quick solve.
Do I need a difference array for rounds up to 10^5?+
No. Sectors is at most 100, so each leg takes at most 100 steps. Direct simulation is around 10^7 operations, which is fine. A difference array is a valid optimization, but it adds bug risk for little gain.
How do I return the answer in the right order?+
Find the maximum count, then loop through the original sectors array in order and keep every label whose count equals the max. Don't sort anything and don't iterate the hash map, since its order isn't guaranteed.
How do I prepare for this in 48 hours?+
Write the simulation once with modulo wrap, then test the two given examples plus a leg where start equals end. Check that the junction sector isn't double-counted. That covers nearly every failure mode for this problem.