PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in array manipulation, sliding-window techniques, and algorithmic efficiency including time and space complexity. It is commonly asked in technical interviews within the Coding & Algorithms domain to probe practical implementation skills for contiguous-data processing, and the level of abstraction is practical application rather than purely conceptual understanding.

  • easy
  • Meta
  • Coding & Algorithms
  • Software Engineer

Compute Sliding Window Averages

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Given a list of numbers `nums` and a positive integer `window_size`, compute the average of every contiguous subarray of length `window_size`. Return a list where each element is the average of one sliding window, in left-to-right order. If `window_size` is greater than the length of `nums`, return an empty list. Example: - Input: `nums = [1, 2, 3, 4, 5]`, `window_size = 3` - Output: `[2.0, 3.0, 4.0]` Explanation: - Window `[1, 2, 3]` -> `2.0` - Window `[2, 3, 4]` -> `3.0` - Window `[3, 4, 5]` -> `4.0` Design an efficient solution.

Quick Answer: This question evaluates proficiency in array manipulation, sliding-window techniques, and algorithmic efficiency including time and space complexity. It is commonly asked in technical interviews within the Coding & Algorithms domain to probe practical implementation skills for contiguous-data processing, and the level of abstraction is practical application rather than purely conceptual understanding.

Return the average of every contiguous window of size window_size.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,2,3,4,5], 3)

Expected Output: [2.0, 3.0, 4.0]

Explanation: Three windows have averages 2, 3, and 4.

Input: ([5,5], 3)

Expected Output: []

Explanation: Window larger than the array returns empty.

Input: ([1,-1,1,-1], 2)

Expected Output: [0.0, 0.0, 0.0]

Explanation: Negative values are included normally.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)