FastPrepBootstrap Mean and Confidence Interval
Problems/Bootstrap Mean and Confidence Interval

Bootstrap Mean and Confidence Interval

Amazon logoAmazon● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for bootstrap means and confidence intervals, with a loop-free optimization follow-up. It omits the draw interface and interval convention; this version supplies recorded draws and linear percentile rules, with vectorization discussed in the editorial. Approximate source match: 75%.

You are given a sample of numbers and a set of recorded resamples of it. Return the mean of the sample and a two-sided percentile bootstrap interval for that mean. This interval is built from the means of the resamples, using the steps below.

data holds n numeric observations and is never empty. Each row of resampleIndices is one resample: n draws made with replacement from data. An index i in a row means that draw picked data[i]. An index may repeat inside a row, and the same row may appear more than once. Use the recorded draws exactly as given.

  1. Compute the arithmetic mean of the original data.
  2. Compute the mean of each resample. There are b resamples, so this gives b means. Sort them from smallest to largest and call the sorted list y.
  3. Let tail = (1 - confidence) / 2. The lower end of the interval is Q(tail) and the upper end is Q(1 - tail), where Q is defined next.

For this exercise, Q is a linear quantile of y. For 0 <= q <= 1, let h = q * (b - 1), lo = floor(h), hi = ceil(h), and w = h - lo. Then Q(q) = (1 - w) * y[lo] + w * y[hi]. The same formula also works when there is only one resample.

Return [observedMean, lowerEndpoint, upperEndpoint]. The first value is the mean of the original data, not the average of the resample means. When confidence is zero, both ends equal the median of the resample means. When confidence is one, the ends are the smallest and the largest resample means.

The given indices make the resampling repeatable. Do not make any new random draws. Write your solution with standard arithmetic and collection operations.

Interview follow-ups

  • Explain how a numerical-array library can compute the resample means without Python-level loops, and discuss its memory cost.
  • Discuss when bootstrap estimates are appropriate for different statistics; explain why the applicability depends on the statistic and sampling assumptions.

Function

bootstrapMeanInterval(data: double[], resampleIndices: int[][], confidence: double) → double[]

Examples

Example 1

data = [1,3]resampleIndices = [[0,0],[0,1],[1,0],[1,1]]confidence = 0.5return = [2,1.75,2.25]

The four resample means are 1,2,2,3. The 25th and 75th percentiles of these means come out to 1.75 and 2.25 by linear interpolation. The original mean is 2, so the answer is that mean followed by the two ends.

Example 2

data = [-5]resampleIndices = [[0],[0],[0]]confidence = 0.95return = [-5,-5,-5]

Every resample and the original data have the same mean -5, so both interval endpoints are -5.

Example 3

data = [0,10,20]resampleIndices = [[0,1,2],[0,0,0],[2,2,2],[1,1,1],[2,0,1]]confidence = 1return = [10,0,20]

The resample means, sorted, are 0,10,10,10,20. Confidence 1 makes the ends the smallest and the largest of these. The mean of the original data is still 10, so it comes first in the answer.

Constraints

  • 1 <= n <= 200 and 1 <= b <= 200, with n * b <= 4000.
  • Every resample row has length n and contains indices in 0..n-1.
  • Every observation is finite and between -1000000 and 1000000.
  • 0 <= confidence <= 1.
  • Use double precision. Each output value may differ from the expected value by at most 10^-7.

More Amazon Phone Screen questions

  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Find Missing and Duplicate IntegerInMobi · PHONE SCREENInMobi interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • K Closest Points to the OriginWhatNot · PHONE SCREENWhatNot interview questions
  • Minimum Fuel Car AlignmentFivetran · PHONE SCREENFivetran interview questions
  • Pick the K Nearest Grid Points to (0, 0)Capital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions

Interview reports that mention this question

  • Amazon Experienced Hire OA and Interviews: 21 Experiences

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
See Amazon hiring insights
Saved
class Solution {
    public double[] bootstrapMeanInterval(double[] data, int[][] resampleIndices, double confidence) {
        // Write your code here
    }
}
Checking account…