JP Morgan Interview | 602 - Senior Lead Engineer | April 2020
- Posted
- 18 Feb 2021
Summary
I interviewed for a Senior Lead Engineer position at JPMC in April 2020. The interview rounds covered data structures and algorithms, core Java collections, and advanced testing concepts.
How it went
I recently interviewed for a Senior Lead Engineer position at JPMC in April 2020. My interview experience was divided into several rounds, touching upon various technical aspects. The initial rounds focused heavily on fundamental data structures and algorithms, where I was challenged with a classic tree construction problem and implementing a generic stack from scratch. Subsequently, the interview delved into core Java concepts, including the characteristics and optimal use cases for different collections, their thread-safety properties, and specifics regarding ConcurrentHashMap and HashSet. Finally, there were questions about advanced testing methodologies using JUnit, particularly concerning how to test private methods and count method invocations for monitoring or verification.
Questions asked (8)
- 01
Construct Binary Tree from Inorder and Postorder Traversal
Data Structures & Algorithms · Medium
Given the inorder traversal sequence:
4 8 2 5 1 6 3 7and postorder traversal sequence:8 4 5 2 6 7 3 1, construct the unique binary tree. Recall that inorder traversal follows LVR (Left, Visit, Right) and postorder traversal follows LRV (Left, Right, Visit). - 02
Implement Generic Stack without Inbuilt Collections
Data Structures & Algorithms · Medium
Open the problemImplement a generic stack that can accept any data type (e.g.,
int,String, or custom objects) without relying on Java's built-inStackorDequeclasses. - 03
Best Collection for Write-Heavy Scenarios
Other
Discuss which Java collection is best suited for scenarios characterized by a higher frequency of write operations and fewer read operations.
- 04
Concurrent Collection with Insertion Order for Write-Heavy Scenarios
Other
Identify a Java collection that not only maintains insertion order but is also efficient for write-heavy scenarios (less read, more write) and ensures thread-safety in a multi-threading environment.
- 05
Thread-Safety of ConcurrentHashMap
Other
Is
ConcurrentHashMapsynchronized and thread-safe? - 06
Thread-Safety and Insertion Order of HashSet
Other
Is
HashSetthread-safe? Does it maintain insertion order? - 07
Testing Private Methods with JUnit
Other
Explain the approaches and considerations for writing test cases for private methods within a class using JUnit.
- 08
Counting Method Invocations for Testing
Other
Describe how one can count the number of times a specific method is invoked, especially in scenarios where a delegator pattern is used. What techniques can be employed to achieve this for testing purposes?