JP Morgan Interview | 602 - Senior Lead Engineer | April 2020

Round 1:

Q1: Construct tree from given order
inorder: 4 8 2 5 1 6 3 7
post order: 8 4 5 2 6 7 3 1

inorder: LVR
post order: LRV


Answer:

      1
    /  \
  2      3
  /\
 4  5   6  7
  \
  8

Q2: Implement Generics stack (to accept int/String/ anything). how to implement without using inbuilt stack
https://leetcode.com/playground/U77gEYzF

Other questions:

- Which collection is best for lesser read and more write
- Which collection is best if you want to maintain insertion order, less read and more right and in multi-threading
- Is concurrentHashmap synchronized/thread safe - Yes
- Is Hashset threadsafe and maintain insertion order ?

Junit test:
- How to write private method testcase
- If you want to count how many times method is being called, how can you do that ?
(Say if you are using delegator, how can you count number of call), how canyou achieve this ?
Comments (2)