{"id":21809936,"url":"https://github.com/ahtrahdis7/node-splitwise-js","last_synced_at":"2025-04-13T21:52:15.870Z","repository":{"id":56825120,"uuid":"382025470","full_name":"ahtrahdis7/node-splitwise-js","owner":"ahtrahdis7","description":"Minimize Cash Flow among a given set of friends who have borrowed money from each other using JavaScript. [200+ NPM Downloads]","archived":false,"fork":false,"pushed_at":"2023-11-27T17:26:40.000Z","size":17,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-02-22T22:46:48.526Z","etag":null,"topics":["algorithm","greedy","javascript","low-level-design","nodejs","split","splitwise","splitwize"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/splitwise-js-map","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahtrahdis7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-01T12:28:04.000Z","updated_at":"2024-01-19T11:43:05.000Z","dependencies_parsed_at":"2023-11-27T18:33:37.472Z","dependency_job_id":"ba49f3c8-1140-4777-902f-fa3d77925474","html_url":"https://github.com/ahtrahdis7/node-splitwise-js","commit_stats":null,"previous_names":["ahtrahdis7/splitwise"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahtrahdis7%2Fnode-splitwise-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahtrahdis7%2Fnode-splitwise-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahtrahdis7%2Fnode-splitwise-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahtrahdis7%2Fnode-splitwise-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahtrahdis7","download_url":"https://codeload.github.com/ahtrahdis7/node-splitwise-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788866,"owners_count":21161726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","greedy","javascript","low-level-design","nodejs","split","splitwise","splitwize"],"created_at":"2024-11-27T13:29:23.598Z","updated_at":"2025-04-13T21:52:15.850Z","avatar_url":"https://github.com/ahtrahdis7.png","language":"TypeScript","readme":"# Splitwise: Minimize Cash Flow Algorithm\n\u003cq\u003eMinimize Cash Flow among a given set of friends who have borrowed money from each other.\u003c/q\u003e \u003cbr\u003e\nGiven a number of friends who have to give or take some amount of money from one another. Design an algorithm by which the total cash flow among all the friends is minimized. \n\n### Approach :\nGreedy.\nSettle the debts of the people with Max and Min. Credits.\n\n### Data Structure Used :\n\n1. Array : To storr the final outputs.\n2. Map : To store and get remaining individual transaction amounts in O(1) time complexity.\n\n### Implementation :\n\u003cpre\u003e\nnpm install splitwise-js-map\n\u003c/pre\u003e\n\u003cpre\u003e\nconst Splitwise = require('splitwise-js-map');\n\nvar input = [    \n    {   \n      'paidBy': 'A',  \n      'paidFor': { 'B': 300, 'C': 40, 'D': 30 } \n    },\n    {   \n      'paidBy': 'B',  \n      'paidFor': { 'A': 50, 'B': 100, 'C': 200 } \n    }\t\n  ]\n\nconst splits = Splitwise(input);\nconsole.log(splits);\n\u003c/pre\u003e\nOutput: [ `from`, `to` , `value`]\n\u003cpre\u003e\n[ [ 'C', 'A', 240 ], [ 'B', 'A', 50 ], [ 'D', 'A', 30 ] ]\n\u003c/pre\u003e\n\n### Updates :\nFeel free to submit PRs for any improvements that you find.\n\n\u003e !! HAPPY CODING !!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahtrahdis7%2Fnode-splitwise-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahtrahdis7%2Fnode-splitwise-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahtrahdis7%2Fnode-splitwise-js/lists"}