FastPrepMinimum Cost with Adjacent Choices Different
Problems/Minimum Cost with Adjacent Choices Different

Minimum Cost with Adjacent Choices Different

Roblox logoRoblox● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reports name Paint House and link Construction Management to Minimum Falling Path Sum II. This version uses the rule they share: the lowest cost where neighboring choices differ. We chose rectangular inputs, the output for the impossible case, and the limits. Our version is about 85% the same as the reported question.

You are given a rectangular cost matrix costs. Choose exactly one column in each row and pay the cost at that position. Consecutive rows must choose different columns; nonconsecutive rows may reuse a column.

For this exercise, assume the matrix represents a sequence of items with the same available choices in every row. Return the minimum total cost satisfying the adjacent-choice rule. Return 0 for no rows and -1 when no valid sequence exists.

Function

minAdjacentChoiceCost(costs: int[][]) → int

Examples

Example 1

costs = [[1,7],[4,2],[3,8]]return = 6

Choose columns 0, 1 and 0, paying 1 + 2 + 3. Reusing column 0 after a gap is allowed.

Example 2

costs = [[3],[5]]return = -1

Only one column is available, so two consecutive rows cannot choose different columns.

Example 3

costs = []return = 0

There are no rows and no cost to pay.

Constraints

  • 0 <= costs.length <= 80.
  • For nonempty input, every row has the same length k, with 1 <= k <= 16.
  • 0 <= costs[r][c] <= 10^6.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • Card Game: Best First-Player ScoreShopify · OAShopify interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)

Roblox interview experiences

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int minAdjacentChoiceCost(int[][] costs) {
        // write your code here
    }

}
Checking account…