FastPrepCount Centaur Friend Requests
Problems/Count Centaur Friend Requests

Count Centaur Friend Requests

Meta logoMeta● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta intern phone screen. The report gives all the friend-request rules and five examples, but no limits on the input size. We added limits. Our version is about 99% the same as the reported question.

A group of centaurs sign up for accounts and may send directed friend requests to one another. You are given their integer ages in ages.

A centaur with age x sends a request to a different centaur with age y only when all of these rules hold:

  1. y >= x / 2 + 7, where the division is real-number division.
  2. y <= x.
  3. If x > 100, then y >= 100.

Count the total number of directed friend requests. Centaurs with the same age are still distinct people, and no centaur may send a request to themself.

Function

countCentaurFriendRequests(ages: int[]) → long

Examples

Example 1

ages = [120,110]return = 1

The 120-year-old centaur sends one request to the 110-year-old centaur. The reverse request is disallowed because the recipient would be older.

Example 2

ages = [120,110,99]return = 1

The 99-year-old recipient is disallowed for both senders over 100, so only the request from age 120 to age 110 is sent.

Example 3

ages = [120,45,230,400,88,300,101]return = 4

Exactly four ordered sender-recipient pairs satisfy every age rule.

Example 4

ages = [101,120,230,400,88,45,55,300]return = 6

Counting valid ordered pairs across all eight distinct centaurs gives six requests.

Example 5

ages = [100,110,120]return = 3

The valid requests are from age 110 to 100 and from age 120 to both 100 and 110.

Constraints

  • 1 <= ages.length <= 2 * 10^5.
  • 1 <= ages[i] <= 10^9.
  • Each position in ages represents a distinct centaur.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Find All Pythagorean TripletsDell Technologies · PHONE SCREEN
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREEN
  • Count Winning Dice Face PairsGoogle · PHONE SCREEN
  • Count Triples That Can Form a TriangleAdobe · PHONE SCREEN
  • 3Sum SmallerSalesforce · ONSITE INTERVIEW
  • Linear InterpolatorTwo Sigma · OA
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEW
  • 3SumAmazon · PHONE SCREEN
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEW
  • Adaptive Calibration ErrorOpenAI · PHONE SCREEN

Interview reports that mention this question

  • Meta Production Engineer Intern Questions: 6 Experiences

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
See Meta hiring insights
Saved
class Solution {
    public long countCentaurFriendRequests(int[] ages) {
      // write your code here
    }
}
Checking account…