Back to problems

Design a Transaction Class

Object-Oriented Programming · Capital One · Medium

Approach 1: Linear Scan Over a List of Account Records The whole problem boils down to one operation: given an account ID, find the balance that belongs to it. The most direct way to express that mapping is a plain list of small records, where each record pairs an ID with a balance. Opening an account appends a fresh record and returns its ID; every other call locates the matching record by walking the list from front to back. Two details make this work. First, uniqueness of…

Checking your access…