FastPrepMake Layer Times Odd
Problems/Make Layer Times Odd

Make Layer Times Odd

Patreon logoPatreon● EasyINTERNOA

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A master's student who applied online for a software engineering internship at Patreon (late-2024 hiring season) posted two screenshots from their online assessment on 2024-10-18. This task is the first of the two. The screenshot sets out the task: a network's layers each have a processing time, one move picks an even value and halves every layer that has exactly that time, and the goal is the fewest moves that leave every time odd. It walks through one example, [2, 4, 8, 16], which takes 4 moves. The screenshot shows no function signature and no limits. The poster rated the difficulty average and marked the assessment as passed. Our choices: the function receives the layer times as an integer array and returns the number of moves; the limits (1 to 10,000 layers, each time from 1 to 10^9) are ours, as are Examples 2 and 3.

A neural network has n layers. The time layer i takes to compute is computationalTime[i].

You may apply the following operation any number of times: choose an even integer c, and every layer whose time is exactly c has its time reduced to c / 2.

Return the minimum number of operations needed so that the time of every layer is odd.

Function

minOperations(computationalTime: int[]) → int

Examples

Example 1

computationalTime = [2, 4, 8, 16]return = 4
  • Choose c = 16: the layer with time 16 becomes 8, giving [2, 4, 8, 8].
  • Choose c = 8: both layers with time 8 become 4, giving [2, 4, 4, 4].
  • Choose c = 4: all three layers with time 4 become 2, giving [2, 2, 2, 2].
  • Choose c = 2: all four layers become 1, giving [1, 1, 1, 1].
  • That is 4 operations. Each of the values 16, 8, 4 and 2 has to be chosen at least once, so fewer is not possible.

Example 2

computationalTime = [40, 6, 40, 3, 20, 1]return = 4
  • Choose c = 40: both layers with time 40 become 20, giving [20, 6, 20, 3, 20, 1].
  • Choose c = 20: all three layers with time 20 become 10.
  • Choose c = 10: those three layers become 5.
  • Choose c = 6: that layer becomes 3, giving [5, 3, 5, 3, 5, 1].
  • The values 40, 20, 10 and 6 each have to be chosen at least once, so the answer is 4.

Example 3

computationalTime = [1, 7, 9]return = 0

Every time is already odd, so no operation is needed and the answer is 0.

Constraints

  • 1 <= n == computationalTime.length <= 104
  • 1 <= computationalTime[i] <= 109

More Patreon interview questions

  • Three SumOA · Seen Apr 2025
  • Sum of Subarray RegionsOA · Seen Oct 2024
  • Binary Cardinality SortingOA · Seen Apr 2023
  • Closest NumbersOA · Seen Apr 2023
  • Maximum Books From BundlesOA · Seen Apr 2023
  • Professors Teaching Outside Their DepartmentOA · Seen Apr 2023
  • Botany QueryOA · Seen Apr 2023
  • Math with Lego BlocksOA · Seen Apr 2023
  • Sliding-Window API Rate LimiterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Employee Importance from a DictionaryPHONE SCREEN · Seen Feb 2026

Similar questions at other companies

  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Maximum MEXAtlassian · OAAtlassian interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Distinct Products After Removing One ElementHSBC · OAHSBC interview questions
  • Maximum Distinct Values After SwapsAkuna Capital · OAAkuna Capital interview questions
  • Min OperationAmazon · OA
  • Find Max Sum with Same First and Last DigitMicrosoft · OAMicrosoft interview questions
All Patreon interview questionsSee Patreon hiring insights
Saved
class Solution {
    public int minOperations(int[] computationalTime) {
        // Write your code here.
    }
}
Checking account…