FastPrepReplace Values at Selected Indices
Problems/Replace Values at Selected Indices

Replace Values at Selected Indices

Akuna Capital logoAkuna Capital● EasyNEW GRADFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A fuller technical interview report gives a list of values, a list of indexes and one fill value, and asks for a new list. Shorter reports describe replacing by position, or say removal or replacement without being clear, or only replacing list values. For those thin recollections we use overwriting by position. We do not claim they fixed that meaning. We chose these: indexes are valid and start at zero, what happens with a repeated index, integer limits, and the exact function signature.

Our version is about 90% the same as the fuller report.

You are given an integer array values, an integer array indices, and an integer fillValue.

Build a new array that starts as a copy of values. At every position listed in indices, put fillValue instead. Every other position keeps its original value. Positions start at zero.

Return the new array and leave both input arrays unchanged. A position may appear in indices more than once. That is the same as listing it once. The order of the entries in indices does not change the result.

Every index is valid. If indices is empty, return an unchanged copy of values. If values is empty, indices is empty too, and you return an empty array.

Function

replaceAtIndices(values: int[], indices: int[], fillValue: int) → int[]

Examples

Example 1

values = [10,20,30,40]indices = [3,1]fillValue = -5return = [10,-5,30,-5]

Start with a copy of values. Position 3 becomes −5, then position 1 becomes −5. Positions 0 and 2 keep 10 and 30.

Example 2

values = [7,7,7]indices = [1,1]fillValue = 0return = [7,0,7]

Both indices name position 1. Writing 0 there twice has the same effect as writing once. The output still has three entries.

Example 3

values = [2,0,1,2]indices = [2]fillValue = -7return = [2,0,-7,2]

The entry 2 in indices is a position, not a value to look for. Only the third entry is replaced. The entries at positions 0 and 3 also equal 2, but they stay unchanged.

Constraints

  • 0 <= values.length <= 2000.
  • 0 <= indices.length <= 4000.
  • -10^9 <= values[i] <= 10^9.
  • -10^9 <= fillValue <= 10^9.
  • 0 <= indices[i] <= 1999.
  • Every index is zero-based and strictly less than values.length. If values is empty, indices is empty.

More Akuna Capital Phone Screen questions

  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Sep 2026
  • Maximum Value in a Binary TreePHONE SCREEN · Seen Sep 2026
  • Tiered Expiring Item StorePHONE SCREEN · Seen Aug 2026
  • Statistics for the Latest K ValuesPHONE SCREEN · Seen Nov 2025
  • Remove Duplicates While Preserving OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
  • Sliding Window MaximumPHONE SCREEN · Seen Oct 2025
  • Evaluate a PolynomialPHONE SCREEN · Seen Oct 2025

Similar questions at other companies

  • Pascal's TriangleBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Sparse Vector Dot Product from TuplesMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Numerically Stable SoftmaxWaymo · PHONE SCREENWaymo interview questions
  • Best Average Student ScoreGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Logger Rate LimiterGoogle · PHONE SCREENGoogle interview questions
  • Minimum StackSnowflake · PHONE SCREENSnowflake interview questions
  • Streaming Entropy, Part 1: Batch EntropyOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
  • Price CheckBlue Origin · PHONE SCREEN
  • Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int[] replaceAtIndices(int[] values, int[] indices, int fillValue) {
        // write your code here
    }
}
Checking account…