Cody

# Problem 2699. From a given cell array of strings, extract the non-unique strings.

Solution 2108763

Submitted on 28 Jan 2020 by Asif Newaz
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
C = {'Ken'; 'GianCarlo'; 'Ken'; 'GianCarlo'; 'Bob'; 'Ken'; 'Sonia'}; repeatedStrings = {'Ken'; 'GianCarlo'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

a = 3 2 3 2 1 3 1 b = 5×1 cell array {'Ken' } {'GianCarlo'} {'Ken' } {'GianCarlo'} {'Ken' } r = 2×1 cell array {'Ken' } {'GianCarlo'}

2   Pass
C = {'A', 'B', 'C', 'A', 'B'}; repeatedStrings = {'A'; 'B'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

a = 2 2 1 2 2 b = 1×4 cell array {'A'} {'B'} {'A'} {'B'} r = 1×2 cell array {'A'} {'B'}

3   Pass
C = {'B', 'A', 'C', 'B', 'A'}; repeatedStrings = {'B'; 'A'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

a = 2 2 1 2 2 b = 1×4 cell array {'B'} {'A'} {'B'} {'A'} r = 1×2 cell array {'B'} {'A'}

4   Pass
C = {'A', 'B', 'C'}; repeatedStrings = cell.empty(0, 1); assert(isequal(extractRepeatedStrings(C), repeatedStrings))

a = 1 1 1 b = 1×0 empty cell array r = 1×0 empty cell array

5   Pass
C = {'A', 'B'; 'C', 'A'; 'B', 'A'}; repeatedStrings = {'A'; 'B'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

a = 3 2 1 3 2 3 b = 5×1 cell array {'A'} {'B'} {'B'} {'A'} {'A'} r = 2×1 cell array {'A'} {'B'}