-
3 Comments
good!
http://www.mathworks.com/help/matlab/ref/unique.html
Why bother coding what has already been coded?
Hello, amin nazari.
Congratulations on devising your own script to satisfy the test cases.
As a point of feedback, I suggest that this function may not be robust/general enough to handle any possible combinations of values in an input vector.
On line c(1,m(ff))=0 zero is introduced as a 'marker' in the new vector c. Given that c was defined as being offset by 10000000 from a, this is equivalent to using a 'marker' value of -10000000 in the vector a.
Suppose that the input vector a were provided as [-10000000 2 2 1]. The above function would then immediately set c = [0 10000002 10000002 10000001]. Notice that a 'genuine' value of zero has occurred, which cannot be distinguished from the 'marker' value that is later introduced, and the correct result could therefore not be obtained for this input.
Suggested Problems
-
2167 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1860 Solvers
-
1514 Solvers
-
305 Solvers
-
Area of an equilateral triangle
6395 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!