PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Vmware

Compute iterative sliding-window sum reduction

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving and array-manipulation skills, focusing on sliding-window and iterative reduction concepts within the Coding & Algorithms domain.

  • medium
  • Vmware
  • Coding & Algorithms
  • Software Engineer

Compute iterative sliding-window sum reduction

Company: Vmware

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Given an integer array `nums` and an integer window size `k`, repeatedly apply the following reduction: - If `len(nums) > k`: replace `nums` with a new array `next` where - `next[i] = sum(nums[i : i + k])` for every valid consecutive window of length `k`. - Thus, `len(next) = len(nums) - k + 1`. - If `len(nums) <= k`: stop and return `sum(nums)`. Return the final sum. ### Example `nums = [1, 1, 1, 2, 1, 2]`, `k = 3` Round 1 (window size 3): - `[1,1,1] -> 3`, `[1,1,2] -> 4`, `[1,2,1] -> 4`, `[2,1,2] -> 5` - New array: `[3, 4, 4, 5]` Round 2 (window size 3): - `[3,4,4] -> 11`, `[4,4,5] -> 13` - New array: `[11, 13]` Stop because `len([11,13]) = 2 <= 3`, return `11 + 13 = 24`. ### Function Signature Implement a function like: - `int reduceSlidingWindowSum(int[] nums, int k)` ### Notes / Constraints (assume) - `nums.length >= 1` - `1 <= k` - Values can be negative; use a wide enough integer type if overflow is possible.

Quick Answer: This question evaluates algorithmic problem-solving and array-manipulation skills, focusing on sliding-window and iterative reduction concepts within the Coding & Algorithms domain.

Vmware logo
Vmware
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0
Loading...

Problem

Given an integer array nums and an integer window size k, repeatedly apply the following reduction:

  • If len(nums) > k : replace nums with a new array next where
    • next[i] = sum(nums[i : i + k]) for every valid consecutive window of length k .
    • Thus, len(next) = len(nums) - k + 1 .
  • If len(nums) <= k : stop and return sum(nums) .

Return the final sum.

Example

nums = [1, 1, 1, 2, 1, 2], k = 3

Round 1 (window size 3):

  • [1,1,1] -> 3 , [1,1,2] -> 4 , [1,2,1] -> 4 , [2,1,2] -> 5
  • New array: [3, 4, 4, 5]

Round 2 (window size 3):

  • [3,4,4] -> 11 , [4,4,5] -> 13
  • New array: [11, 13]

Stop because len([11,13]) = 2 <= 3, return 11 + 13 = 24.

Function Signature

Implement a function like:

  • int reduceSlidingWindowSum(int[] nums, int k)

Notes / Constraints (assume)

  • nums.length >= 1
  • 1 <= k
  • Values can be negative; use a wide enough integer type if overflow is possible.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Vmware•More Software Engineer•Vmware Software Engineer•Vmware Coding & Algorithms•Software Engineer Coding & Algorithms
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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.