← Bloomberg Interview Insights

Bloomberg·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Bloomberg SWE interview with a sorting/counting problem that looks easy until you actually sit down and think about the edge cases. Pretty standard technical screen vibe.

Questions Asked (1)

Q1

Given an array of ages, count the total number of directed friend requests sent, where person A sends a request to person B only if B is greater than half of A plus 7, B is at most A, and A and B are different people.

Algorithms & Data Structures
Author's notes

My first instinct was brute force O(n^2) and I coded it up fine, but then they asked about scale.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints and edge cases, then derive the condition for a valid request: for each A, B must satisfy max(0.5*A + 7, 0) < B <= A and B != A. Since B must be less than A, sort the array and for each A, count the number of elements in the range (0.5*A + 7, A) using binary search, summing these counts. This yields an O(n log n) solution.

Pro tip: Mention that the condition 'B is greater than half of A plus 7' can be rewritten as B > A/2 + 7, and since B <= A, this implies A > 14. Also, note that the problem counts directed requests, so each valid (A, B) pair is counted once for A as sender.

1. Clarify the problem

Restate the conditions for a valid friend request: B > A/2 + 7, B <= A, and A != B. Confirm that we need to count all such directed pairs (A, B) from the given array of ages.

2. Derive the valid range for B

For a given A, the valid B values are integers in (A/2 + 7, A]. Since B must be less than A, the range is (A/2 + 7, A). Also, note that A must be greater than 14 for the range to be non-empty.

3. Choose an efficient algorithm

Sort the array to enable binary search. For each A, use binary search to find the number of elements in the range (A/2 + 7, A). Sum these counts to get the total number of directed requests.

4. Handle edge cases and duplicates

Consider cases where no valid requests exist (e.g., all ages <= 14). If there are duplicate ages, ensure that each occurrence is treated as a separate person, so counts are multiplied appropriately.

5. Analyze complexity and test

State that the time complexity is O(n log n) due to sorting and binary searches, and space complexity is O(1) or O(n) depending on sorting. Walk through a small example to verify correctness.

Key Points to Mention

  • The condition B > A/2 + 7 and B <= A implies A > 14, so ages <= 14 cannot send requests.
  • Sorting the array allows efficient counting of valid B for each A using binary search.
  • The problem counts directed pairs, so each valid (A, B) is counted once for A as sender.
  • Duplicates in the array represent distinct people, so counts should include all occurrences.
  • Time complexity is O(n log n) and space complexity is O(1) if sorting in-place or O(n) otherwise.
  • Edge cases: empty array, all ages <= 14, or all ages equal.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.