Determine minimal substitutions and removals
SalesforceSoftware Engineer · Online AssessmentLast updated
This question evaluates string manipulation and adjacency-constraint handling in the first task and sequence analysis with minimal-removal and subsequence reasoning in the second, targeting competencies such as local transformation logic, subsequence recognition, and optimization under input constraints.
Question
Given a list of words, determine the minimum number of character substitutions required so that, in every word, no two adjacent characters are identical.
Given an array of n unique integers, determine the minimum number of elements that must be removed so the array becomes "almost sorted"—meaning that after the removals, deleting at most one additional element would make the remaining array strictly ascending.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.