Find Number of Perfect Pairs
Updated
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:
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