Given a network of people, we will try to minimize the number of transactions using C++. We will finally print the amount a person has to give or receive.
We will take a graph as an input of a network of people who needs to pay money to another person or he/she need to receive money from another person. We will use C++ language and we will try to minimize the number of transactions.
Now we will make two sets called debit and credit and we will calculate a person's gain and loss and we will put them in the set respectively. Then we will pick the person who has maximum debit and then we will try to clear the person in credit in descendent order.
Finally, we will be printing the amount a person has to give or receive.
Submitted by Shaik Ateeq ur Rahman (ateeq)
Download packets of source code on Coders Packet