← Bank of America Interview Insights

Bank of America·Data Scientist·Online Assessment (OA)·Intermediate

Intermediate
Apr 2026

Summary

Got a coding problem for a Data Scientist role at Bank of America that felt more like a software engineering screen than anything data-related. One question, parsing English number phrases into integers, and it had enough edge cases to keep you busy for a while.

Questions Asked (1)

Q1

Given a string containing an English phrase representing an integer between negative 999,999,999 and 999,999,999, write a function to parse it and return the numeric value. The input uses standard English number words including 'negative', 'zero', 'one' through 'nineteen', the tens words up to 'ninety', 'hundred', 'thousand', and 'million'. Note that 'hundred' is never used when 'thousand' would apply (so 1500 is 'one thousand five hundred', not 'fifteen hundred').

Algorithms & Data Structures
Author's notes

This looked manageable at first glance and then I started thinking about the edge cases.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then propose a token-based parsing algorithm that processes the string from left to right, maintaining a running total and a current segment value. Explain how to handle multipliers like 'hundred', 'thousand', and 'million' by combining values appropriately, and finally discuss testing and validation.

Pro tip: Mention that you would write unit tests for boundary cases like 'zero', 'negative one', and numbers around thousand and million boundaries, and that you would consider using a dictionary for word-to-number mapping to keep the code clean and efficient.

1. Clarify requirements and edge cases

Ask about input format, case sensitivity, and whether the input is guaranteed to be well-formed. Identify edge cases such as 'zero', negative numbers, and numbers with multiple scales (e.g., 'one million two hundred thousand').

2. Design the parsing algorithm

Propose a token-based approach: split the string into words, map each word to its numeric value, and process tokens sequentially. Maintain a 'current' value for the current segment and a 'total' value for the overall number.

3. Handle multipliers and scales

Explain how to handle 'hundred' (multiply current by 100), 'thousand' (multiply current by 1000 and add to total, then reset current), and 'million' (multiply current by 1,000,000 and add to total, then reset current).

4. Implement and test

Write the function, ensuring correct handling of negative numbers by checking for 'negative' at the start. Test with a variety of cases including boundaries and complex numbers.

5. Discuss complexity and optimizations

Analyze time and space complexity (O(n) time, O(1) space for fixed vocabulary). Mention potential optimizations like using a hash map for word-to-number lookup.

Key Points to Mention

  • Tokenization: splitting the input string into individual words.
  • Mapping words to numbers using a dictionary (e.g., 'one' -> 1, 'twenty' -> 20).
  • Handling multipliers: 'hundred' multiplies the current segment, 'thousand' and 'million' multiply and add to the total.
  • Managing negative numbers by checking for the 'negative' keyword and applying the sign at the end.
  • Edge cases: 'zero', numbers with no 'hundred' (e.g., 'one thousand five'), and numbers spanning multiple scales.
  • Time and space complexity: O(n) time, O(1) space for fixed vocabulary.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.