PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Visa

Maintain pair-sum counts under replacements

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to design dynamic data structures and perform algorithmic complexity analysis for maintaining pair-sum counts under element replacements, testing skills in efficient query/update handling and scalability.

  • Medium
  • Visa
  • Coding & Algorithms
  • Software Engineer

Maintain pair-sum counts under replacements

Company: Visa

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You are given two integer arrays A and B and a list of operations: ( 1) Query(T): return the number of pairs (i, j) such that A[i] + B[j] = T. ( 2) Replace(idx, val): set B[idx] = val. Return an array containing the result of each Query in order. Example: A = [1, 3], B = [2, 4]; operations: Query ( 5), Replace(0, 3), Query ( 4) -> output [2, 1]. Design a data structure to support very large inputs efficiently and state the time and space complexity of your approach.

Quick Answer: This question evaluates the ability to design dynamic data structures and perform algorithmic complexity analysis for maintaining pair-sum counts under element replacements, testing skills in efficient query/update handling and scalability.

Related Interview Questions

  • Solve Two Algorithm Challenges - Visa (hard)
  • Solve Three Array Coding Problems - Visa (medium)
  • Design rotating warehouse simulator with closures - Visa (Medium)
  • Compute distinct sums from limited coins - Visa (Medium)
Visa logo
Visa
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0

You are given two integer arrays A and B and a list of operations: (

  1. Query(T): return the number of pairs (i, j) such that A[i] + B[j] = T. (
  2. Replace(idx, val): set B[idx] = val. Return an array containing the result of each Query in order. Example: A = [1, 3], B = [2, 4]; operations: Query ( 5), Replace(0, 3), Query (
  3. -> output [2, 1]. Design a data structure to support very large inputs efficiently and state the time and space complexity of your approach.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

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