Problem 1755. Fix the last element of a cell array

Note: this is lifted directly from Puzzler for a Monday (on MATLAB Answers) by the cyclist.


Given a cell array of strings


and a particular string value


ensure that B is the last element of the cell array. If it isn't, move it to the end of A.

You cannot assume that B appears at all (in which case return A unchanged), but you can assume B does not appear more than once.

So in the example,


Solution Stats

32.67% Correct | 67.33% Incorrect
Last Solution submitted on Jul 16, 2020

Problem Recent Solvers212

Suggested Problems

More from this Author49

Problem Tags