FastPrepAllocate Workers for a Production Ratio
Problems/Allocate Workers for a Production Ratio

Allocate Workers for a Production Ratio

Barclays logoBarclays● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Barclays full-time online assessment. The report gives one production-ratio case and its worker counts. It leaves out a general function signature, what to do when numbers do not divide evenly, the input limits, and the output format. We chose those and kept the same exact-allocation idea. Our version is about 93% the same as the reported question.

A factory must produce two products in a fixed quantity ratio. You are given positive integers total, firstRatio, secondRatio, firstRate, and secondRate.

  • The factory must produce exactly total items.
  • The first and second product quantities must have ratio firstRatio : secondRatio.
  • One first-product worker produces firstRate items per day.
  • One second-product worker produces secondRate items per day.

The ratio divides total exactly, and each product quantity is divisible by its corresponding per-worker rate. Return a two-element integer array containing the required first-product worker count followed by the required second-product worker count.

Function

allocateWorkers(total: int, firstRatio: int, secondRatio: int, firstRate: int, secondRate: int) → int[]

Examples

Example 1

total = 2160firstRatio = 2secondRatio = 1firstRate = 18secondRate = 24return = [80,30]

The ratio has three total parts, so the product quantities are 2160 * 2 / 3 = 1440 and 2160 * 1 / 3 = 720. The required worker counts are 1440 / 18 = 80 and 720 / 24 = 30.

Example 2

total = 1000firstRatio = 3secondRatio = 2firstRate = 20secondRate = 25return = [30,16]

The product quantities are 600 and 400. Dividing by the corresponding daily rates gives 30 and 16 workers.

Example 3

total = 630firstRatio = 1secondRatio = 2firstRate = 7secondRate = 14return = [30,30]

The two product quantities are 210 and 420. Although the quantities differ, the rates make both worker counts equal to 30.

Constraints

  • 1 <= total, firstRatio, secondRatio, firstRate, secondRate <= 10^9.
  • firstRatio + secondRatio <= 2 * 10^9.
  • total * firstRatio and total * secondRatio fit in a signed 64-bit integer.
  • total * firstRatio and total * secondRatio are each divisible by firstRatio + secondRatio.
  • Each resulting product quantity is divisible by its corresponding per-worker rate.

More Barclays Online Assessment questions

  • Find a String Within One Mismatch of AllOA · Seen Nov 2026
  • Minimum Steps RequiredOA · Seen Apr 2024
  • Find Maximum Possible GCD 🥭OA · Seen Mar 2024

Similar questions at other companies

  • Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
  • Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
  • Maximum Student-Teacher DistanceChubb · OAChubb interview questions
All Barclays interview questionsSee Barclays hiring insights
Saved
class Solution {
    public int[] allocateWorkers(int total, int firstRatio, int secondRatio, int firstRate, int secondRate) {
        // Write your code here.
    }
}
Checking account…