An accounting firm records all the transactions in a linear sequence. Each transaction can have an integer value, and the goal for a clean audit is to adjust all transactions so that every value becomes zero.
The firm has a tool that can perform a switch operation and adjust the value of a sequence of transactions. In one switch, it can select a contiguous group of transactions from the start and either add or subtract one unit of value from each transaction in the group.
Find the minimum number of switch required to convert every transaction to 0.