Cody

# Problem 53. Duplicates

Solution 1910367

Submitted on 23 Aug 2019 by Tetsuji Tsuda
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
strs = {'aa','bb','aa','aa'}; correct = {'aa'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

uni_s = 1×2 cell array {'aa'} {'bb'} cat_s = 1×4 categorical array aa bb aa aa cnt_s = 3 1 l_uni = 2 ret = 0×0 empty cell array cnt = 1 ret = 1×1 cell array {'aa'} cnt = 2 dups = 1×1 cell array {'aa'}

2   Pass
strs = {'10','11','12'}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

uni_s = 1×3 cell array {'10'} {'11'} {'12'} cat_s = 1×3 categorical array 10 11 12 cnt_s = 1 1 1 l_uni = 3 ret = 0×0 empty cell array cnt = 1 dups = 0×0 empty cell array

3   Pass
strs = {'zzz','zzz','zzz'}; correct = {'zzz'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

uni_s = 1×1 cell array {'zzz'} cat_s = 1×3 categorical array zzz zzz zzz cnt_s = 3 l_uni = 1 ret = 0×0 empty cell array cnt = 1 ret = 1×1 cell array {'zzz'} cnt = 2 dups = 1×1 cell array {'zzz'}

4   Pass
strs = {'a','b','c','b','d','c'}; correct = {'b','c'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

uni_s = 1×4 cell array {'a'} {'b'} {'c'} {'d'} cat_s = 1×6 categorical array a b c b d c cnt_s = 1 2 2 1 l_uni = 4 ret = 0×0 empty cell array cnt = 1 ret = 1×1 cell array {'b'} cnt = 2 ret = 1×2 cell array {'b'} {'c'} cnt = 3 dups = 1×2 cell array {'b'} {'c'}

5   Pass
strs = {}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

uni_s = 0×1 empty cell array cat_s = 0×0 empty categorical array cnt_s = [] l_uni = 0 ret = 0×0 empty cell array cnt = 1 dups = 0×0 empty cell array