FastPrepRunning Through Walls with Limited Energy
Problems/Running Through Walls with Limited Energy

Running Through Walls with Limited Energy

Scale AI logoScale AI● HardNEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Scale AI online assessment. We rebuilt the question. You start at 0 and move one unit at a time in either direction. Walls sit at half-integer spots. You want to cross as many distinct walls as you can within your energy. A wall's thickness replaces the normal step cost, and each repeat crossing is charged again. An integer gap x stands for a wall at x + 0.5. Our version is about 96% the same as the reported question.

You start at integer coordinate 0 on a number line with energy energy. A unit move crosses the gap between two adjacent integers.

A wall position x represents a wall at x+0.5. Crossing that gap in either direction costs its positive thickness; every gap without a wall costs 1. Every crossing costs energy, including repeated crossings of the same wall.

Return the maximum number of distinct walls that can be crossed while spending at most energy.

Function

maximumDistinctWalls(energy: long, wallPositions: int[], thicknesses: int[]) → int

Examples

Example 1

energy = 4wallPositions = [-1,0]thicknesses = [2,2]return = 1

Either adjacent wall costs 2. Crossing both requires visiting both sides and costs 6.

Example 2

energy = 6wallPositions = [-1,0]thicknesses = [2,2]return = 2

Cross one wall, return through it, then cross the other: 2+2+2.

Example 3

energy = 5wallPositions = [0,2]thicknesses = [3,1]return = 2

Moving right crosses the first wall for 3, one ordinary gap for 1, and the second wall for 1.

Constraints

  • 0 <= wallPositions.length == thicknesses.length <= 200000.
  • Wall positions are unique integers in [-1000000000,1000000000].
  • 1 <= thicknesses[i] <= 1000000000.
  • 0 <= energy <= 10^18.

More Scale AI Online Assessment questions

  • Part 2: Batch Access ReviewOA · Seen Nov 2026
  • Part 1: The Narrowest KeyOA · Seen Nov 2026
  • Build Sessions from Unordered Events (Part 1)OA · Seen Oct 2026
  • Match Billing Charges to User Sessions (Part 2)OA · Seen Oct 2026
  • Four-Player Trick-Taking Card Game SimulationOA · PHONE SCREEN · Seen Aug 2026
  • Free Windows Between Busy IntervalsOA · PHONE SCREEN · Seen Apr 2026
  • Compare Labeling Worker AnnotationsOA · Seen Mar 2025
  • Count Stable Server SubsegmentsOA · Seen Nov 2024
  • Distinct OR Values of Increasing SubsequencesOA · Seen Nov 2024
  • Relative Score Graph ComponentsOA · Seen Sep 2023

Similar questions at other companies

  • Minimize Warehouse Transfer CostAmazon · OA
  • Make the Array PositiveAtlassian · OAAtlassian interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Optimal TransferSnowflake · OASnowflake interview questions
  • Minimum AmountBelvedere Trading · OA
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Last-Element RelocationsChubb · OAChubb interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions

Interview reports that mention this question

  • Scale AI OA: What It Tests (2026)
  • Scale AI New Grad SWE and MLE Question Bank
  • Scale AI New Grad SWE OA Running Through Walls: 1 Experience

Scale AI interview experiences

  • Scale AI Forward Deployed Engineer Debugging Round: 1 Experience
  • Scale AI ML Research Engineering Intern Interviews: 1 Experience
  • Scale AI SWE Intern Debugging Interview: 9 Experiences
All Scale AI interview questionsSee Scale AI hiring insights
Saved
class Solution {
    public int maximumDistinctWalls(long energy, int[] wallPositions, int[] thicknesses) {
        // write your code here
    }
}
Checking account…