{"id":20845889,"url":"https://github.com/crusty0gphr/bank-request-processor","last_synced_at":"2025-05-09T02:47:07.058Z","repository":{"id":171706606,"uuid":"383145799","full_name":"crusty0gphr/bank-request-processor","owner":"crusty0gphr","description":"A solution to one of my coding interview questions. Complete solution - written in GoLang. Task - \"You've been asked to program a bot for a popular bank that will automate the management of incoming requests\". ","archived":false,"fork":false,"pushed_at":"2021-07-28T08:20:19.000Z","size":3,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T21:33:52.512Z","etag":null,"topics":["codesignal","codesignal-solutions","go","golang","interview-questions"],"latest_commit_sha":null,"homepage":"","language":"Go","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/crusty0gphr.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}},"created_at":"2021-07-05T13:11:37.000Z","updated_at":"2024-08-04T09:24:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"510a9dee-8b15-49c8-b1a6-57fb8071f38f","html_url":"https://github.com/crusty0gphr/bank-request-processor","commit_stats":null,"previous_names":["haroutthebest/bank-request-processor","crusty0gphr/bank-request-processor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crusty0gphr%2Fbank-request-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crusty0gphr%2Fbank-request-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crusty0gphr%2Fbank-request-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crusty0gphr%2Fbank-request-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crusty0gphr","download_url":"https://codeload.github.com/crusty0gphr/bank-request-processor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253181394,"owners_count":21866989,"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":["codesignal","codesignal-solutions","go","golang","interview-questions"],"created_at":"2024-11-18T02:14:18.786Z","updated_at":"2025-05-09T02:47:07.019Z","avatar_url":"https://github.com/crusty0gphr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## **Bank Requests**\n\n_A solution to one of my coding interview questions. Complete solution - written in **GoLang**_\n\n---\n### Task:\n\nYou've been asked to program a bot for a popular bank that will automate the management of incoming requests. There are three types of requests the bank can receive:\n \n\u003e***transfer i j sum***: request to transfer sum amount of money from the ith account to the ***j-th*** one; deposit ***i*** sum: request to deposit sum amount of money in the ***i-th*** account, withdraw ***i*** sum: request to withdraw sum amount of money from the ***i-th*** account.\n\nYour bot should also be able to process invalid requests. There are two types of invalid requests: invalid account number in the requests; deposit / withdrawal of a larger amount of money than is currently available.\n\nFor the given list of accounts and requests, return the state of accounts after all requests have been processed, or an array of a single element `[- \u003crequest_id\u003e]` (please note the minus sign), where ***\u003crequest_id\u003e*** is the **1-based** index of the first invalid request.\n\nExample for `accounts = [10, 100, 20, 50, 30]` and `requests = [\"withdraw 2 10\", \"transfer 5 1 20\", \"deposit 5 20\", \"transfer 3 4 15\"]`, the output should be `bankRequests(accounts, requests) = [30, 90, 5, 65, 30]`.\n\nHere are the states of accounts after each request:\n* `\"withdraw 2 10\": [10, 90, 20, 50, 30]`\n* `\"transfer 5 1 20\": [30, 90, 20, 50, 10]`\n* `\"deposit 5 20\": [30, 90, 20, 50, 30]`\n* `\"transfer 3 4 15\": [30, 90, 5, 65, 30],` which is the answer\n\nFor `accounts = [20, 1000, 500, 40, 90]` and `requests = [\"deposit 3 400\", \"transfer 1 2 30\", \"withdraw 4 50\"]`, the output should be `bankRequests(accounts, requests) = [-2]`.\n\nAfter the first request, accounts becomes equal to `[20, 1000, 900, 40, 90]`, but the second one turns it into `[-10, 1030, 900, 40, 90]`, which is invalid. Thus, the second request is invalid, and the answer is `[-2]`. Note that the last request is also invalid, but it shouldn't be included in the answer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrusty0gphr%2Fbank-request-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrusty0gphr%2Fbank-request-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrusty0gphr%2Fbank-request-processor/lists"}