FastPrepStateful Neuron Matrix Update
Problems/Stateful Neuron Matrix Update

Stateful Neuron Matrix Update

Scale AI logoScale AI● MediumNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This practice version preserves the source's firing value, exact-three transition, decrement rules, nonnegative clamp, simultaneous update, and space-optimization follow-up. Eight-neighbor geometry and unchanged omitted cases, including positive cells with two or three firing neighbors, are practice assumptions. A separate loop report describes similar matrix structure with different Game of Life rules but does not supply those rules; using this neuron-rule baseline for that recollection is a disclosed practice interpretation. Editorial estimate: about 86% agreement with the reported core.

A matrix cell with value 0 is a firing neuron; a positive value is non-firing. Update every cell simultaneously using its up to eight surrounding neighbors.

  • A firing neuron becomes 6 when exactly three neighbors are firing; otherwise it stays 0.
  • A non-firing neuron loses 2 when zero or one neighbor is firing.
  • It loses 1 when more than three neighbors are firing.
  • With exactly two or three firing neighbors, a non-firing neuron is unchanged.
  • Values never fall below zero.

Return the matrix after one simultaneous update.

Function

updateNeuronMatrix(grid: int[][]) → int[][]

Examples

Example 1

grid = [[1,0,1],[0,5,0],[1,1,1]]return = [[1,0,1],[0,5,0],[0,1,0]]
grid
012010110502111
→
return
012010110502010
Moved or new

The center has exactly three firing neighbors and, as a non-firing value, remains 5. Each bottom corner has one firing neighbor and decreases to 0.

Example 2

grid = [[5,5],[5,5]]return = [[3,3],[3,3]]
grid
01055155
→
return
01033133
Moved or new

Every neuron has zero firing neighbors, so each value decreases by 2.

Example 3

grid = [[0,0],[0,0]]return = [[6,6],[6,6]]
grid
01000100
→
return
01066166
Moved or new

Each corner has exactly three neighbors and all three are firing.

Constraints

  • 1 <= grid.length, grid[i].length <= 1000.
  • All rows have equal length.
  • 0 <= grid[i][j] <= 1000000000.

More Scale AI Onsite Interview questions

  • Task Scheduler with DependenciesONSITE INTERVIEW · Seen Jul 2026
  • Best Poker Category with a JokerPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
  • Format and Validate a Model ResponseONSITE INTERVIEW · Seen Apr 2026
  • Clock Hand Angle with Subsecond PrecisionONSITE INTERVIEW · Seen Dec 2025
  • Four-Player Matching Card GameONSITE INTERVIEW · Seen Feb 2025
  • Rotate an Array to the RightONSITE INTERVIEW · Seen Oct 2024
  • Rich-Text Segment Normalization and Bold ToggleONSITE INTERVIEW · Seen Apr 2024
  • Minimum Distance Matching in a ForestPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2024
  • Shortest Distance Between Two NodesONSITE INTERVIEW · Seen Jan 2024
  • Fit Beta Parameters by Maximum LikelihoodONSITE INTERVIEW · Seen Sep 2022

Similar questions at other companies

  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Spiral MatrixNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Tic-Tac-Toe Move WinnersByteDance · ONSITE INTERVIEWByteDance interview questions
  • Trace Every Water Drop to Its Resting DestinationGoogle · ONSITE INTERVIEWGoogle interview questions
  • Stochastic Gradient Descent with MomentumMeta · ONSITE INTERVIEWMeta interview questions
  • Cyclic Fuel Command SimulationWaymo · ONSITE INTERVIEWWaymo interview questions
  • Generate a Spiral MatrixMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Minesweeper Board UpdateUber · ONSITE INTERVIEWUber interview questions
  • Spiral Matrix with ObstaclesTemu · ONSITE INTERVIEWTemu interview questions

Interview reports that mention this question

  • Scale AI New Grad SWE and MLE Question Bank
  • Scale AI New Grad SWE Two-Day Onsite: 1 Experience

Scale AI interview experiences

  • Scale AI OA: What It Tests (2026)
  • 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[][] updateNeuronMatrix(int[][] grid) {
        // write your code here
    }
}
Checking account…