Problem · Array

Find Max Number of Pairs

Learn this problem
EasyRoblox logoRobloxINTERNOA
See Roblox hiring insights

Problem statement

Given an array, find the numbers with the same number of digits that can form the largest number of different pairs. For example, given the array {1, 9, 23, 30, 54, 103}, the possible pairs are {1, 9}, {23, 30}, {23, 54}, {30, 54}, and the output should be 4.

Function

findMaxNumberOfPairs(nums: int[]) → int

Examples

Example 1

nums = [1, 9, 23, 30, 54, 103]return = 4
The possible pairs with the same number of digits are:
  • {1, 9}
  • {23, 30}
  • {23, 54}
  • There are a total of 4 different pairs, so the output is 4.

    Constraints

    🐌🧡🦖

    More Roblox problems

    drafts saved locally
    public int findMaxNumberOfPairs(int[] nums) {
      // write your code here
    }
    
    nums[1, 9, 23, 30, 54, 103]
    expected4
    checking account