This project is based on Split-wise app which is used to minimize the number of transactions for making debit and credit functions smoother which is implemented in C++.
Suppose there are N friends who went outside for a trip in their holidays. Few of the friends carried less amount of money , so they borrowed money from their friends and promised to return it later, but after they completed their trip and reached home it was great messy to deal with high number of transactions between them.
So, to solve this problem I thought the problem can be made easier if we make the transactions minimal, so i implemented an algorithm to minimize cashflows in c++.
Here, I calculated the net gain or loose for each one of my friends and then stored them into multiset , and then picked the minimal value and the maximum value , so the minimal value is the debit amount and the maximum value is credit amount and then i found the minimum of these values.
And stored in variable settlement.
Then at last i added the settlement to debit and secondly i decremented the settlement from credit.
We will do this till multiset becomes empty.
At last we got everyones net amount to be zero and our number of transactions got minimized.
Submitted by UDDESHYA PANKAJ (uddeshya146)
Download packets of source code on Coders Packet