At Stripe, an existing utility scans a list of integers with nested loops to find values that appear more than once. Rewrite it for better performance.
Implement a function find_duplicates(nums) that returns all distinct duplicate values in ascending order, along with how many times each value appears.
nums, a list of integers[value, count] for every integer that appears at least twicevalue in ascending orderdef find_duplicates(nums):