PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Maximize total bandwidth of data channel pairs

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design efficient algorithms for combinatorial optimization and selection under constraints, testing understanding of array manipulation, ordered pair counting, and aggregation of bandwidth sums.

  • hard
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Maximize total bandwidth of data channel pairs

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Take-home Project

You are optimizing how information flows through a network of processing nodes. There are `n` processing nodes. The bandwidth capability of the *i*-th node is given by an integer array `bandwidth` of length `n`. There are `streamCount` data channels that must each be connected to **two** processing nodes: - one node acts as the **main** connection; - the other acts as the **secondary** connection. For a single data channel with main node index `i` and secondary node index `j`, its data flow is defined as: > `dataFlow = bandwidth[i] + bandwidth[j]` A ***pair of nodes*** `(i, j)` used for one channel must be **unique** among all channels, with the following rules: - A pair is identified by the ordered indices `(main, secondary)`. - `(i, j)` and `(j, i)` are considered **different** pairs. - It is allowed to choose `i == j`, i.e., a channel may use the same node for both main and secondary. - The same node index can appear in many different pairs (across different channels), as long as the ordered pair `(i, j)` itself is unique for each channel. Your goal is to select exactly `streamCount` distinct ordered pairs `(main, secondary)` so that the **sum of dataFlow across all data channels is maximized**. ### Input - An integer `n` (number of nodes). - An integer array `bandwidth` of length `n`, where `bandwidth[i]` is the bandwidth of node `i`. - An integer `streamCount` — the number of data channels. You may assume: - `1 <= n <= 10^5`. - `1 <= bandwidth[i] <= 10^9`. - `1 <= streamCount <= n^2` (since there are `n^2` possible ordered pairs `(i, j)` including `i == j`). ### Output - Return a single integer: the **maximum possible total dataFlow**, i.e., the maximum possible sum of `bandwidth[main] + bandwidth[secondary]` over all `streamCount` channels. ### Complexity requirement Design an algorithm that works efficiently for `n` and `streamCount` up to about `10^5` (much better than enumerating all `n^2` pairs explicitly when `n` is large).

Quick Answer: This question evaluates a candidate's ability to design efficient algorithms for combinatorial optimization and selection under constraints, testing understanding of array manipulation, ordered pair counting, and aggregation of bandwidth sums.

Related Interview Questions

  • Count Connected Components in an Undirected Graph - Amazon (medium)
  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
Amazon logo
Amazon
Oct 1, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0

You are optimizing how information flows through a network of processing nodes.

There are n processing nodes. The bandwidth capability of the i-th node is given by an integer array bandwidth of length n.

There are streamCount data channels that must each be connected to two processing nodes:

  • one node acts as the main connection;
  • the other acts as the secondary connection.

For a single data channel with main node index i and secondary node index j, its data flow is defined as:

dataFlow = bandwidth[i] + bandwidth[j]

A pair of nodes (i, j) used for one channel must be unique among all channels, with the following rules:

  • A pair is identified by the ordered indices (main, secondary) .
  • (i, j) and (j, i) are considered different pairs.
  • It is allowed to choose i == j , i.e., a channel may use the same node for both main and secondary.
  • The same node index can appear in many different pairs (across different channels), as long as the ordered pair (i, j) itself is unique for each channel.

Your goal is to select exactly streamCount distinct ordered pairs (main, secondary) so that the sum of dataFlow across all data channels is maximized.

Input

  • An integer n (number of nodes).
  • An integer array bandwidth of length n , where bandwidth[i] is the bandwidth of node i .
  • An integer streamCount — the number of data channels.

You may assume:

  • 1 <= n <= 10^5 .
  • 1 <= bandwidth[i] <= 10^9 .
  • 1 <= streamCount <= n^2 (since there are n^2 possible ordered pairs (i, j) including i == j ).

Output

  • Return a single integer: the maximum possible total dataFlow , i.e., the maximum possible sum of bandwidth[main] + bandwidth[secondary] over all streamCount channels.

Complexity requirement

Design an algorithm that works efficiently for n and streamCount up to about 10^5 (much better than enumerating all n^2 pairs explicitly when n is large).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon 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.