Box Fro~yo
Reported by candidates from Box's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're up against Box's froyo machine problem in June 2025. A circular menu, a starting position, a target flavor. You need the minimum moves to reach it going left or right. This is a distance problem on a circle, not a traversal nightmare. Find the target index, calculate both directions, return the smaller number. StealthCoder will catch the formula if you blank on the circular math.
The problem
The Box office is thinking about investing in a rotating frozen yogurt (froyo) machine. The froyo machine has a menu with frozen yogurt flavors that may be included. The machine must move through the flavors one at a time, either moving left or right. The machine is circular, so when the last flavor in the flavors array is reached in either direction, the next flavor is at the other end of the array. Given the name of the next flavor needed, determine the minimum number of left or right moves to reach it. Function Description Complete the function flavorchanger in the editor below. flavorchanger has the following parameter(s): Returns int: minimum number of moves required to reach the desired flavor Constraints 1 ≤ n ≤ 100 0 ≤ startIndex ≤ n-1 1 ≤ length of flavors[i] and target ≤ 100 target is in flavors
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is recognizing this isn't a search problem. You locate the target flavor's index in the array, then calculate two distances: clockwise (target - start) and counter-clockwise (n - (target - start)). Handle negative indices with modulo. The circle means going right from the end wraps to the start, and vice versa. Most candidates overthink this and simulate movement. Don't. The pattern is math, not simulation. StealthCoder will spot the index and distances instantly if you freeze mid-interview.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Box Fro~yo 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Box's OA.
Box reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Box Fro~yo FAQ
Is this really just finding the minimum of two distances?+
Yes. Index the target, calculate clockwise and counter-clockwise distances, return the minimum. The circle constraint is a red herring. No BFS, no simulation. Pure arithmetic.
What's the gotcha with negative indices?+
If target is before start going left, the counter-clockwise distance is n minus the absolute difference. Use modulo or explicit branches to avoid off-by-one errors.
Does the target always exist in the array?+
The constraints confirm it. Target is in flavors. No null checks needed. Focus on the distance math.
How do I handle edge cases in 48 hours?+
Test with target at start (0 moves), target at end (n-1), and mid-array. Verify both directions wrap correctly. That's enough.
Is this problem still asked at Box?+
Yes, as of June 2025. It's a warm-up, not a blocker. If you nail the circular distance formula, you've won.