PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Design compressed vector and compute dot product

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of data structure design, sequence compression concepts (such as run-length patterns), and numeric algorithm efficiency for computing operations like the dot product, within the Coding & Algorithms domain, and it probes both conceptual understanding and practical application for large-scale data and engineering trade-offs. It is commonly asked to assess the ability to represent long repeating runs compactly and to reason about space/time complexity, iteration semantics, and edge cases such as differing run boundaries and accumulation/overflow concerns without relying on full decompression.

  • easy
  • Google
  • Coding & Algorithms
  • Software Engineer

Design compressed vector and compute dot product

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

## Problem You are given very long integer vectors where **many adjacent elements repeat** (e.g., long runs of the same value). Storing the full array is memory-expensive. ### Task 1. **Design a compact data structure** to store such a vector more efficiently than a raw `int[]`/`vector<int>`. 2. Using your compact representation, implement a method to compute the **dot product** of two vectors `A` and `B` of equal length `n`: \[ A \cdot B = \sum_{i=0}^{n-1} A[i] \times B[i] \] ### Requirements / Constraints - `n` can be very large (e.g., up to \(10^7\) or more), so avoid full decompression when possible. - Values fit in 32-bit signed integers; the dot product may require a 64-bit accumulator. - Your structure should support: - Building from an input array - Iterating through the logical sequence (implicitly) - Computing dot product between two compressed vectors efficiently ### Clarifications to state during interview - Assume “many repeats” primarily means **runs of identical adjacent values** are common. - Vectors are dense (not necessarily sparse / not mostly zeros). ### Deliverables - Describe the data structure and its space complexity. - Describe the dot product algorithm using the compressed form and its time complexity. - Provide key edge cases (e.g., negative values, different run boundaries, overflow concerns).

Quick Answer: This question evaluates understanding of data structure design, sequence compression concepts (such as run-length patterns), and numeric algorithm efficiency for computing operations like the dot product, within the Coding & Algorithms domain, and it probes both conceptual understanding and practical application for large-scale data and engineering trade-offs. It is commonly asked to assess the ability to represent long repeating runs compactly and to reason about space/time complexity, iteration semantics, and edge cases such as differing run boundaries and accumulation/overflow concerns without relying on full decompression.

Related Interview Questions

  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
  • Consolidate On-Call Rotation Segments - Google (medium)
  • Solve Flower Placement and Directory Deletion - Google (medium)
Google logo
Google
Jan 11, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0
Loading...

Problem

You are given very long integer vectors where many adjacent elements repeat (e.g., long runs of the same value). Storing the full array is memory-expensive.

Task

  1. Design a compact data structure to store such a vector more efficiently than a raw int[] / vector<int> .
  2. Using your compact representation, implement a method to compute the dot product of two vectors A and B of equal length n :

A⋅B=∑i=0n−1A[i]×B[i]A \cdot B = \sum_{i=0}^{n-1} A[i] \times B[i]A⋅B=∑i=0n−1​A[i]×B[i]

Requirements / Constraints

  • n can be very large (e.g., up to 10710^7107 or more), so avoid full decompression when possible.
  • Values fit in 32-bit signed integers; the dot product may require a 64-bit accumulator.
  • Your structure should support:
    • Building from an input array
    • Iterating through the logical sequence (implicitly)
    • Computing dot product between two compressed vectors efficiently

Clarifications to state during interview

  • Assume “many repeats” primarily means runs of identical adjacent values are common.
  • Vectors are dense (not necessarily sparse / not mostly zeros).

Deliverables

  • Describe the data structure and its space complexity.
  • Describe the dot product algorithm using the compressed form and its time complexity.
  • Provide key edge cases (e.g., negative values, different run boundaries, overflow concerns).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ 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.