Problem 1237. It's race time! Write a faster function than the test suite call of unique().
Write a function to get unique elements of a vector faster than unique()! Input will be a vector (of integers or floating point numbers) of any size. The order of the returned vector is unimportant.
Example: Input: x = [1 1 2 2 3 3]; Output: [1 2 3];
Input: x = [0.1 3.1 2.1 2.0 3.1]; Output: [0.1 3.1 2.1 2.0]; % or any order
Solution Stats
Problem Comments
-
7 Comments
it even cannot pass on my own computer, but....
Jeremy, please increase the size of the third case. Performance tests are not made with small samples (unless they are run several times)...because many other factors may affect the time (alternating processes, server overload, memory usage, etc). A regular CPU is always multi-tasking.
About your problem with arrays, try adding a comma between lists.
Solution Comments
Show commentsProblem Recent Solvers31
Suggested Problems
-
Renaming a field in a structure array
1551 Solvers
-
1029 Solvers
-
68 Solvers
-
Compress strings (not springs)
207 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
639 Solvers
More from this Author7
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!