Banking System
Asked at Airbnb
Reported by the problem's creator, not verified
You are building an in-memory banking system as the class BankingSystem. Every method takes the call's timestamp as its first argument.
Examples
Example 1
Input: init =
[], operations =[["create_account",[1,"a"]],["create_account",[2,"a"]],["create_account",[3,"b"]],["deposit",[4,"a",100]],["deposit",[5,"z",5]],["transfer",[6,"a","b",30]],["transfer",[7,"a","a",1]],["transfer",[8,"a","z",1]],["transfer",[9,"z","a",1]],["transfer",[10,"b","a",31]],["transfer",[11,"b","a",30]],["deposit",[12,"b",1]],["transfer",[13,"a","b",100]]]Output:
[true,false,true,100,null,70,null,null,null,null,0,1,0]Explanation:
aandbare created; the second creation ofafails. After 100 is deposited intoa, transferring 30 tobreturnsa's new balance, 70. A transfer to the same account, to or from an unknown account, or of more than the source holds returnsnull.bholds exactly 30, so moving 30 back succeeds and leaves 0, andacan then move its whole balance of 100.