PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates algorithmic problem-solving skills involving array processing, counting and combinatorics under conditional constraints and frequency handling.

  • medium
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Count friend requests based on age rules

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given an array `ages`, where `ages[i]` is the age of the `i`-th person. A person of age **A** will send a **friend request** to a person of age **B** if all conditions hold: 1. \(B > 0.5 \times A + 7\) 2. \(B \le A\) Each request is **directed** (A→B). A person cannot send a request to themselves. Return the **total number of friend requests** that will be sent. ## Input - `ages`: integer array ## Output - An integer: total number of directed friend requests. ## Constraints (you may assume typical interview bounds) - \(1 \le n \le 2\times 10^4\) - \(1 \le ages[i] \le 120\) ## Examples 1) `ages = [16, 16]` - Each 16-year-old can request the other (since \(16 > 0.5\cdot16 + 7 = 15\) and \(16 \le 16\)) - Total = 2 2) `ages = [20, 30, 100, 110, 120]` - Compute total directed requests that satisfy the rules.

Quick Answer: This question evaluates algorithmic problem-solving skills involving array processing, counting and combinatorics under conditional constraints and frequency handling.

Count ordered friend requests between people using the standard age rules.

Constraints

  • Inputs are provided as Python literals compatible with the function signature.
  • Return a deterministic value exactly matching the requested output.

Examples

Input: ([16, 16],)

Expected Output: 2

Explanation: Two reciprocal requests.

Input: ([16, 17, 18],)

Expected Output: 2

Explanation: Mixed ages.

Input: ([20, 30, 100, 110, 120],)

Expected Output: 3

Explanation: Over-100 rule.

Hints

  1. Start with a direct data structure representation.
  2. Handle edge cases before the main loop.
Last updated: Jun 27, 2026

Loading coding console...

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.

Related Coding Questions

  • Minimize Travel Assignment Cost - Bloomberg (medium)
  • Determine Balloon Popping Time - Bloomberg (medium)
  • Solve meeting and tree problems - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)