FastPrepMinimum-Cost Color Sequence
Problems/Minimum-Cost Color Sequence

Minimum-Cost Color Sequence

OpenAI logoOpenAI● MediumFULLTIMENEW GRADOAPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an OpenAI online assessment for full-time and new grad roles. The original report gives three daily color-price lists, different colors on consecutive days, a unique minimum-cost sequence, and three examples. Here we use an equivalent matrix of day by color, and return the color sequence as a string. We chose the function details and the number limits.

Our version is about 98% the same as the reported question.

For each day i, costs[i][0], costs[i][1], and costs[i][2] are the costs of choosing blue, green, or red.

Choose exactly one color per day, and never choose the same color on consecutive days. Return the unique minimum-cost color sequence as a string using b, g, and r.

Function

minimumCostColorSequence(costs: int[][]) → String

Examples

Example 1

costs = [[1,5,9],[4,2,8],[7,6,1]]return = "bgr"

Choosing blue, green, then red costs 1 + 2 + 1 = 4, which is the unique minimum.

Example 2

costs = [[7,2,5]]return = "g"

With one day, the least expensive choice is green.

Example 3

costs = [[1,3,4],[1,5,6],[1,7,4]]return = "bgb"

The unique valid minimum-cost sequence is bgb, with total cost 7.

Example 4

costs = [[18,13,12],[12,15,16],[1,7,4],[9,9,8]]return = "rgbr"

The unique valid minimum-cost sequence is rgbr, with total cost 36.

Example 5

costs = [[100,22,99],[1,20,99],[76,1,5],[14,2,12]]return = "gbrg"

The unique valid minimum-cost sequence is gbrg, with total cost 30.

Constraints

  • 1 <= costs.length <= 100000.
  • costs[i].length == 3.
  • 1 <= costs[i][j] <= 1000000.
  • The minimum-cost valid sequence is unique.

More OpenAI Online Assessment questions

  • Count Routes Through Four Shop TypesOA · Seen Oct 2026
  • Digit-Sum Sequence Join PointOA · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026
  • Password Clues and the Next CommandOA · Seen Oct 2026
  • Longest Increasing Price SubsequenceOA · Seen Oct 2026
  • Macaron Order PriceOA · Seen Oct 2026
  • Shortest Atom Action PathOA · Seen Oct 2026
  • Simplify a Quadratic ExpressionOA · Seen Oct 2026
  • Largest Microorganism After ConsumptionOA · Seen Oct 2026
  • Invert or Blur an ImageOA · Seen Sep 2026

Similar questions at other companies

  • Maximum Subarray Sum with One DeletionServiceNow · PHONE SCREENServiceNow interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • Maximum Product of a Contiguous SubarrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Fewest Coins CombinationBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
  • Jump GamePaytm · PHONE SCREENPaytm interview questions
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
  • House RobberVisa · PHONE SCREENVisa interview questions

Interview reports that mention this question

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public String minimumCostColorSequence(int[][] costs) {
        // Write your code here.
    }
}
Checking account…