FastPrepReplacing Val πŸ“
Problems/Replacing Val πŸ“

Replacing Val πŸ“

Two Sigma logoTwo Sigma● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Sup πŸ‘‹!

This time the agency will give you:

  • An int 2D arr
  • A position within the input 2D arr
  • A so called replacing val

What they want you to do:

Replace the val at the starting position with the provided replacing val. Repeat this process for all positions connected to the starting position via sides with the same val as the starting position.

Function

replacingNum(replacingVal: int, arr: int[][], pos: int[]) β†’ int[][]

Examples

Example 1

replacingVal = 2arr = [[0, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 1, 0, 1, 0]]pos = [1, 2]return = [[0, 2, 0, 0, 0], [2, 2, 2, 0, 0], [2, 2, 0, 0, 0], [0, 2, 0, 1, 0]]

Every cell with the starting value that is connected to the start through shared sides becomes the replacing value. The cell with the same value that touches none of them stays unchanged.

Constraints

  • Unknown for now 🀲

More Two Sigma interview questions

  • IPO Share AllocationOA Β· Seen Sep 2026
  • Sewer Drainage PartitionOA Β· Seen Sep 2026
  • Daily Temperature By TownOA Β· Seen Sep 2026
  • Linear InterpolatorOA Β· Seen Sep 2026
  • Online No-Intercept Linear RegressionOA Β· Seen Sep 2026
  • Balanced Split String with WildcardsOA Β· Seen Aug 2026
  • Closest ColorOA Β· Seen Aug 2026
  • Price-Time Order MatchingPHONE SCREEN Β· Seen Aug 2026
  • Piecewise Linear Interpolation and ExtrapolationOA Β· Seen May 2026
  • Calculate y/x using PatchOA Β· Seen Nov 2025

Similar questions at other companies

  • Connected GroupsVisa Β· OAVisa interview questions
  • Find Largest House AreaHSBC Β· OAHSBC interview questions
  • Count Connected Equal TilesIntuit Β· OAIntuit interview questions
  • Count Battleships by SizeDeloitte Β· OADeloitte interview questions
  • Word SearchBloomberg LP Β· OA Β· PHONE SCREEN Β· ONSITE INTERVIEWBloomberg LP interview questions
  • Number of IslandsGoldman Sachs Β· OA Β· PHONE SCREEN Β· ONSITE INTERVIEWGoldman Sachs interview questions
  • House Bounds in a Ragged GridRippling Β· OA Β· PHONE SCREENRippling interview questions
  • Increasing Paths, part 1Hudson River Trading Β· OAHudson River Trading interview questions
  • Cave AdvantureMeta Β· OAMeta interview questions
  • Maximum Damage PatchGecko Robotics Β· OA Β· PHONE SCREEN
All Two Sigma interview questionsSee Two Sigma hiring insights
Saved
class Solution {
    public int[][] replacingNum(int replacingVal, int[][] arr, int[] pos) {
        // write your code here (lc733 might help)
    }

}
Checking account…