Question 211 · 357 in bank
You are parsing a log file that contains three columns: a timestamp, an account number (a string), and a transaction amount (a number). You want to calculate the sum of all transaction amounts for each unique account number efficiently. Which data structure should you use?
Show answer
Answer: B
Explanation
B. A hash table. A hash table allows for fast insertion and lookup of data, which would be useful in this case for quickly looking up the transaction amount for a given account number and adding it to the total. A linked list, two-dimensional array, and comma-delimited string would not be as efficient for this purpose.
Source: Adapted from community discussion — omermahgoub