← Questions

Fewest conflicts when merging branches

0
AmazonCodingLast asked Jan 2026

Several branches have to be merged, and the order of the merges changes how many commit conflicts come up. Given the branches and how conflicts arise between them, return the fewest conflicts any merge order can produce. Trying every order works only for tiny inputs; find a dynamic-programming solution.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding