Pair Left and Right Shoes by Size
Problem statement
A shoe rack contains left shoes and right shoes in various integer sizes. Given the sizes of every left shoe and every right shoe, return whether every shoe can be paired with exactly one opposite-side shoe of the same size.
Function
canPairShoes(leftSizes: int[], rightSizes: int[]) → booleanExamples
Example 1
leftSizes = [7,8,7]rightSizes = [7,7,8]return = trueEvery left shoe has one right shoe of the same size.
Example 2
leftSizes = [6,6]rightSizes = [6,7]return = falseOne left size-6 shoe and the right size-7 shoe remain unmatched.
Constraints
0 <= leftSizes.length, rightSizes.length <= 100000.1 <= size <= 1000000000.