FastPrepMinimum Cost to Remove Stones
Problems/Minimum Cost to Remove Stones

Minimum Cost to Remove Stones

Airbnb logoAirbnb● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported question.

There are n stones in a row, indexed from 0 to n - 1. Stone i has two associated costs: oneNeighborCost[i] and twoNeighborCost[i].

Remove every stone in any order. At the moment stone i is removed, its cost is:

  • twoNeighborCost[i] if both immediately adjacent stones i - 1 and i + 1 still exist.
  • oneNeighborCost[i] if exactly one of those immediately adjacent stones still exists.
  • 0 if neither immediately adjacent stone still exists.

An index outside the row does not contain a stone. Return the minimum possible total cost of removing all stones.

Function

minimumRemovalCost(oneNeighborCost: int[], twoNeighborCost: int[]) → long

Examples

Example 1

oneNeighborCost = [3,4,5]twoNeighborCost = [10,1,10]return = 1

Remove stone 1 first for cost 1. Its removal leaves both end stones without an immediate neighbor, so both are then removed for free.

Example 2

oneNeighborCost = [1,10,1]twoNeighborCost = [5,1,5]return = 1

Remove the middle stone first for cost 1. Both end stones are then isolated and can be removed for free.

Constraints

  • 1 <= n <= 5 * 10^4.
  • oneNeighborCost.length == twoNeighborCost.length == n.
  • 1 <= oneNeighborCost[i], twoNeighborCost[i] <= 1000.

More Airbnb Online Assessment questions

  • Bouncing DiagonalsOA · Seen Dec 2026
  • Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
  • Garden Sprinkler PlacementOA · Seen Dec 2026
  • Theme Park Shuttle Wait TimeOA · Seen Dec 2026
  • Count Card Duel RoundsOA · Seen Nov 2026
  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026
  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026

Similar questions at other companies

  • At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
  • Maximum Sum of HeightsVirtu Financial · OAVirtu Financial interview questions
  • Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
  • Get Minimum IncrementIBM · OAIBM interview questions
  • Jump Game with Prime-3 StepsUber · OAUber interview questions
  • Maximum Payout with Context SwitchesPhonePe · OAPhonePe interview questions

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public long minimumRemovalCost(int[] oneNeighborCost, int[] twoNeighborCost) {
      // Write your code here.
    }
}
Checking account…