Back to problems

Minimum Conflicts in Merging Two Branches

Algorithm · Amazon · Hard

You are given two strings, primary and secondary, each describing the commits on its respective branch. Combine them into one sequence while meeting these conditions: Characters from either input must remain in the same order they had in that input; in other words, the result must be an interleaving of the two strings. A character represents commit priority, where alphabetically earlier letters have greater priority. For instance, a outranks b. Call a pair of positions a…

Checking your access…