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

57.33% Correct | 42.67% Incorrect
Last solution submitted on Oct 13, 2016
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more