Implement a function named find_missing_and_repeating that identifies a repeating number and a missing number in an array of integers. The array contains numbers from 1 to n, where one number appears twice and one number is missing.
Input Requirements
The function should accept two parameters:
arr: A list of integers of length n, where elements are expected to be in the range from 1 to n.
n: An integer representing the length of the list arr (1 ≤ n ≤ 10^6).
Output Requirements
The function should return a list containing two integers:
The first integer is the repeating number.
The second integer is the missing number.
Implementation Constraints
The solution must be efficient in terms of time (ideally O(n) complexity) and space.
The implementation should utilize a dictionary (unordered_map) to track the occurrence of numbers.
File Structure
Write the solution in a file named /app/solution.py.
Example
Input:
python
arr = [3, 1, 3, 4, 2]
n = 5
Output:
python
[3, 5]
This indicates that the repeating number is 3 and the missing number is 5.