Given an unsorted array arr of positive integers. One number a from the set [1, 2,....,n] is missing and one number b occurs twice in the array. Find numbers a and b.
Note: The test cases are generated such that there always exists one missing and one repeating number within the range [1,n].
Topics
Companies
Articles
Examples:
Expected Time Complexity: O(n)
Expected Space Complexity: O(1)
Constraints:
2 <= arr.size() <= 10^6
1 <= arr[i] <= arr.size()
Companies:
SamsungWalmartTCSInfosys
Topics:
Array
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.