FastPrepFind Number of Perfect Pairs
Problems/Find Number of Perfect Pairs

Find Number of Perfect Pairs

LinkedIn logoLinkedIn● MediumOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

A perfect pair (x, y) is such that min( | x - y |, | x + y | ) <= min( | x |, | y |) and max( | x - y |, | x + y | ) >= max( | x |, | y |). Given an array of unsorted integers, find the number of perfect pairs.

Function

findNumberOfPerfectPairs(nums: int[]) → int

Complete the function findNumberOfPerfectPairs in the editor.

findNumberOfPerfectPairs has the following parameter:

  1. int[] nums: an array of integers

Returns int: the number of perfect pairs

Examples

Example 1

nums = [2, -3, 5]return = 2

(2, -3) and (-3, 5) are perfect pairs

More LinkedIn interview questions

  • Allocate Mailboxes with Squared DistanceONSITE INTERVIEW · Seen Nov 2026
  • Find Leaves of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Max Points on a LineONSITE INTERVIEW · Seen Nov 2026
  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Sqrt(x)PHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
  • Sliding-Window Means with IEEE Special ValuesHeadlands Technologies · OAHeadlands Technologies interview questions
  • Last Object to Fall Off the TableConfluent · OAConfluent interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Power-of-Two Removal OperationsIBM · OAIBM interview questions

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int findNumberOfPerfectPairs(int[] nums) {
      // write your code here
    }

}
Checking account…