Minimum Nonreciprocal Bandits
Updated
Problem statement
Every bandit must aim at exactly targetsPerBandit distinct other bandits. A bandit cannot aim at itself, and no pair may aim at each other.
Find the minimum number of participating bandits for which this is possible. For this exercise, assume the two-target case in the first example is generalized to the supplied positive target count, with an exact integer result. You only return the minimum count; you do not output a targeting arrangement.
Complete minimumBandits(targetsPerBandit).
Function
minimumBandits(targetsPerBandit: int) → intExamples
Example 1
targetsPerBandit = 2return = 5The two-target case needs five bandits. Arrange them in a cycle and let each aim at the next two; no pair aims at each other.
Example 2
targetsPerBandit = 1return = 3Three bandits can form one directed cycle. Two bandits would have to aim at each other.
Example 3
targetsPerBandit = 3return = 7In a cycle of seven, each bandit aims at the next three. The reverse offsets are four through six, so no reciprocal pair occurs.
Constraints
- For this exercise, assume
1 <= targetsPerBandit <= 1000000000. - All required targets are distinct and different from the aiming bandit.
- The returned minimum fits a signed 32-bit integer.
More IMC Trading Online Assessment questions
- Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
- Grid Paths with Override PassesOA · Seen Oct 2026
- Weighted LFU CacheOA · Seen Sep 2026
- Rock JumpingOA · Seen Aug 2026
- Stack Batch RemovalOA · Seen Aug 2026
- Chain of CommandOA · Seen Aug 2026
- Choose ContainersOA · Seen Aug 2026
- Sub-matrix SumsOA · Seen Jul 2026
- Sub-matrix SumsOA · Seen Jul 2026
- Can Every Package Fit in a BoxOA · Seen Jul 2026
Similar questions at other companies
- Drawing EdgeWeRide · OAWeRide interview questions
- Drawing EdgeIBM · OAIBM interview questions
- Drawing EdgeSnowflake · OASnowflake interview questions
- Connected Components with Divisor ThresholdInMobi · OAInMobi interview questions
- Minimum Numeric Code TransformationAdobe · OAAdobe interview questions
- Profitable Currency Exchange CycleOptiver · OAOptiver interview questions
- Can Sort Permutation in Given MovesAmazon · OA
- Minimum Number of Permutation Operations 👑Geneva Trading · OA
- Relative Score Graph ComponentsScale AI · OAScale AI interview questions
- Count OperationsWells Fargo · OAWells Fargo interview questions