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 comments
Loading...
Problem Recent Solvers19
Suggested Problems
-
2418 Solvers
-
1345 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2543 Solvers
-
Matrix indexing with two vectors of indices
777 Solvers
-
Create a matrix with difference of each row of input matrix
76 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!