Skip to content

brizdotdev/PP-Tech-Test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PP Tech Test Solution

No AI assistance was used in creating this solution

Missing Number Finder

We know that the following information from the question:

  • Numbers in the collection start at 0
  • Numbers in the collection are distinct
  • Numbers in the collection are consecutive
  • There is only one missing number

We also know that the largest element of the array is the same as the length of the array. i.e n = array.Count

We can therefore create a new collection with elements 0 through n and use the LINQ Except method to find the missing element and use LINQ Single or LINQ First to return the result given that we know there will be only one missing element.

Since the LINQ Except method internally uses a HashSet, the time complexity of this implementation is O(n).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages