Problem 58663. Find duplicate number from a vector of size n + 1 containing numbers from 1:n
From a given vector of size n + 1, return the duplicate number.
Constraints
The vector can only contain numbers from 1 to n inclusive
Only 1 number is duplicate.
Example -
x = [1 2 3 3]
The size of the vector is 4. Therefore n = 3 and it contains numbers from only 1 to 3 (inclusive). However there is just 1 duplicate number which is 3.
Return the value 3
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
-
2249 Solvers
-
619 Solvers
-
Back to basics 25 - Valid variable names
324 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
606 Solvers
-
Replace multiples of 5 with NaN
440 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!