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 Solvers20
Suggested Problems
-
Number of 1s in the Binary Representation of a Number
491 Solvers
-
Program an exclusive OR operation with logical operators
803 Solvers
-
Remove from a 2-D matrix all the rows that contain at least one element less than or equal to 4
140 Solvers
-
401 Solvers
-
Solve a System of Linear Equations
15281 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!