FastPrepPrime Factor Visitation
Problems/Prime Factor Visitation

Prime Factor Visitation

Maven Securities logoMaven Securities● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Maven Securities intern online assessment. The report does not show the formal limits on the numbers. Our version is about 97% the same as the reported question.

Alex has a row of light bulbs that are initially either on or off. The bulb at 1-based position i has state states[i - 1], where 0 means off and 1 means on.

Process the values in numbers from left to right. For each value:

  1. Find its distinct prime factors.
  2. For every such factor p, flip each bulb whose 1-based position is a multiple of p.

A factor is used only once for one value, even when it appears repeatedly in that value's prime factorization. The same factor may be processed again for another value in numbers, causing its bulbs to flip again.

Return the final state of every bulb after all values have been processed.

Function

lightBulbs(states: int[], numbers: int[]) → int[]

Examples

Example 1

states = [1,1,0,0,1,1,0,1,1,1]numbers = [3,4,15]return = [1,0,0,1,0,0,0,0,1,1]

The distinct prime factors are {3} for 3, {2} for 4, and {3, 5} for 15.

  • Factor 3 flips positions 3, 6, and 9.
  • Factor 2 flips positions 2, 4, 6, 8, and 10.
  • The final value 15 flips multiples of 3, then multiples of 5.

The final states are [1,0,0,1,0,0,0,0,1,1].

Constraints

  • 1 <= states.length <= 10^5
  • 1 <= numbers.length <= 10^5
  • Each states[i] is either 0 or 1.
  • 1 <= numbers[i] <= 10^5

More Maven Securities Online Assessment questions

  • Resource AllocationOA · Seen Aug 2026

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Proportional Momentum Investment StatisticsOptiver · OAOptiver interview questions
  • Sort an Array with Rotate and FlipAmazon · OA
  • Total Waiting Time for Handmade ItemsMicrosoft · OAMicrosoft interview questions
  • Prefix Scores With the Running MaximumC3.ai · OAC3.ai interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
All Maven Securities interview questionsSee Maven Securities hiring insights
Saved
class Solution {
    public int[] lightBulbs(int[] states, int[] numbers) {
        // Write your code here
    }
}
Checking account…