I implemented an optimized algorithm which will help groups of people in splitting bills.
Required: Make sure you've C++14 compiler for this to work. in case you don't have C++14 compiler you can use GFG IDE : https://ide.geeksforgeeks.org/kU9QXoPjc9
Sample Test case :
4 3
0 1 10
1 2 5
2 3 2
1
1
2 0 7
0
Output:
################# WELCOME TO QUICK-SPLIT ####################
Enter the number of people and the number of transaction
ThankYou!
In the next 3 lines please enter the index of the person who paid the amount followed by the index of the person who owe it
1 should pay amount $5 to 0
2 should pay amount $3 to 0
3 should pay amount $2 to 0
Do you want to add more transaction ?,if yes then press 1 else press 0
Enter the number of transactions you want to addon
In the next 1 lines please enter the index of the person who paid the amount followed by the index of the person who owe it
1 should pay amount $4 to 2
3 should pay amount $2 to 0
1 should pay amount $1 to 0
Do you want to add more transaction ?,if yes then press 1 else press 0
Total number of Transactions occurred are 3
Added extra functionality for updating and adding extra transaction. You can add more trancasitons later after the calculation.