This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Merge Conflicts" covers key patterns like Strings.
"At Amazon, developers want to merge primary and secondary source control branches into a unified branch while preserving the order of commits from each branch. Each character of a branch represents a commit's priority, with lower alphabetical order indicating higher priority. A conflict occurs when, in the merged branch, a commit with lower priority is placed before a commit with higher priority. Your task is to find the minimum number of conflicts in any valid merge of primary and secondary branches. ### Example primary = "zc" secondary = "d" There are three possible merge arrangements: - "zdc" with 2 merge conflicts ("z" being lower priority is placed before higher priority commits 'c' and 'd') - Similarly, "zdc" with 3 merge conflicts - Similarly, "dzc" with 2 merge conflicts The minimum number of merge conflicts possible is 2. ### Function Description The function getMinimumConflicts takes the following input: string primary: the commit sequence of the primary branch string secondary: the commit sequence of the secondary branch ### Returns int: the minimum number of conflicts after a valid merge"
Join thousands of developers practicing for Amazon.