Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 748 Bytes

File metadata and controls

18 lines (13 loc) · 748 Bytes

Two Missing Numbers

Problem Description

Given an array containing all the numbers from 1 to n except two, find the two missing numbers.

eg.

missing([4, 2, 3]) = 1, 5

Implementation

My solution finds the missing integer under the time complexity of O(n), where n is the number of elements in the source array. The solution generates the result with assumption that no duplicates exist, which allows for an implementation that needs achieves constant space complexity O(1).