Katkat

Determine minimal substitutions and removals

SalesforceSoftware Engineer · Online Assessment

Last 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.