JP Morgan interview experience Real time questions & tips from candidates to crack your interview

SDE - Intern

JP Morgan
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Do at-least 2 good projects and you must know every bit of them.
Tip 2 : Must do Previously asked Interview as well as Online Test Questions.
Tip 3 : Have a deep understanding of all core concepts.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Focus on skills, projects and experiences more.
Tip 2 : Have at-least 2 good projects explained in short with all important points covered.

Interview rounds

01
Round
Easy
Online Coding Test
Duration45 minutes
Interview date7 Aug 2020
Coding problem2

This was an online proctured coding test where we had 2 questions to solve under 45 minutes. Both the questions were of difficulty Easy to Medium.

1. Next Greater Element

Moderate
20m average time
90% success
0/80
Asked in companies
ZSMicrosoftUber

You are given an array arr of length N. You have to return a list of integers containing the NGE(next greater element) of each element of the given array. The NGE for an element X is the first greater element on the right side of X in the array. Elements for which no greater element exists, consider the NGE as -1.

For Example :

If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
Problem approach

1) Push the first element to stack.
2) Pick rest of the elements one by one and follow the following steps in loop.
2.1) Mark the current element as next.
2.2) If stack is not empty, compare top element of stack with next.
2.3) If next is greater than the top element, Pop element from stack. next is the next greater element for
the popped element.
2.4) Keep popping from the stack while the popped element is smaller than next. next becomes the next
greater element for all such popped elements.
3) Finally, push the next in the stack.
4) After the loop in step 2 is over, pop all the elements from the stack and print -1 as the next element for them.

TC : O(N), where N=size of the array
SC : O(N)

Try solving now

2. Top View of Binary Tree

Moderate
25m average time
70% success
0/80
Asked in companies
Thought WorksSamsung R&D InstituteMicrosoft

You are given a Binary Tree of 'n' nodes.


The Top view of the binary tree is the set of nodes visible when we see the tree from the top.


Find the top view of the given binary tree, from left to right.


Example :
Input: Let the binary tree be:

Example

Output: [10, 4, 2, 1, 3, 6]

Explanation: Consider the vertical lines in the figure. The top view contains the topmost node from each vertical line.
Problem approach

The approach is to use the preorder traversal of the tree to traverse the tree and check that we have visited the
current vertical level and if visited then we can check for the smaller horizontal level node and store it. Else we can
just update the vertical level as visited and store the node and horizontal level of the current node.


1) We have to create the map to check whether the horizontal level is visited or not as it will state the horizontal
distance of the node from the root node. Where key will represent the horizontal distance and the value is the pair
containing the value and level of each node.

2) We will traverse the tree using the preorder traversal.

3) Every time we check if the level of the current horizontal distance is less than the max level seen till now then we
will update the value and the level for this horizontal distance.

4) We will pass level-1 for the left child and level+1 for the right child to get the vertical level.

5) Print the values present in the map.

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date7 Aug 2020
Coding problem3

In this round , the interviewer first asked me two algorithmic questions. This was followed by some standard questions from OOPS.

1. Increasing Path In Matrix

Moderate
25m average time
75% success
0/80
Asked in companies
IntuitAppleJP Morgan

You are given a 2-D matrix ‘mat’, consisting of ’N’ rows and ‘M’ columns. The element at the i-th row and j-th column is ‘mat[i][j]’.

From mat[i][j], you can move to mat[i+1][j] if mat[i+1][j] > mat[i][j], or to mat[i][j+1] if mat[i][j+1] > mat[i][j].

Your task is to find and output the longest path length if you start from (0,0) i.e from mat[0][0] and end at any possible cell (i, j) i.e at mat[i][j].

Note :
Consider 0 based indexing.
Problem approach

1) Create a 2D integer matrix ‘dp’ of size n*m, where dp[i][j] stores the length of the longest path ending at ‘mat[i][j]’. Fill the entire matrix ‘dp[][]’ with INT_MIN initially.

2) Assign dp[0][0]:= 1

3) Run a loop where ‘i’ ranges from 1 to ‘m-1’ and for each ‘i’ if ‘mat[0][i]’ > mat[0][i-1], then assign dp[0][i] := dp[0][i-1] + 1, otherwise break the loop.

4) Run a loop where ‘i’ ranges from 1 to ‘n-1’ and for each ‘i’ if ‘mat[i][0]’ > mat[i-1][0]’, then assign dp[i][0] := dp[i-1][0] + 1, otherwise break the loop

5) Run two nested loops, In outer loop ‘i’ ranges from 1 to n-1, and inner loop ‘j’ ranges from 1 to m-1, and for each (i, j) do the following.
5.1) If mat[i][j] > mat[i][j-1], then assign dp[i][j] = max(dp[i][j], dp[i][j-1] + 1).
5.2) If mat[i][j] > mat[i-1][j], then assign dp[i][j] = max(dp[i][j], dp[i-1][j] + 1).

6) The largest value of the matrix ‘dp[][]’ will be the length of the longest path starting from (0, 0), we need to return this value.


TC : O(N*M), where N, M represents the number of rows and columns respectively.
SC : O(N*M)

Try solving now

2. OOPS based Questions

What do you mean by virtual functions in C++?

Problem approach

1) A C++ virtual function is a member function in the base class that you redefine in a derived class. It is declared
using the virtual keyword.
2) It is used to tell the compiler to perform dynamic linkage or late binding on the function.
3) When the function is made virtual, C++ determines which function is to be invoked at the runtime based on the
type of the object pointed by the base class pointer.

3. Spiral Matrix

Easy
0/40
Asked in companies
OYOJP MorganAdobe

You are given a N x M matrix of integers, return the spiral path of the matrix

Example Of Spiral Path

Spiral Path

Problem approach

spiralPrint(matrix[][], R, C, rows, cols):

1) Check for base cases, i.e. if outside the boundary of the matrix then return.
2) Print the first row from left to right of the matrix i.e from column ‘C’ to ‘cols’, print the elements of the Rth row.
3) Print the last column from top to bottom of the matrix i.e from row ‘R’ to ‘rows’, print the elements of the (cols)th column.
4) Print the last row from right to left of the matrix i.e from column ‘cols’ to ‘C’, print the elements of the (rows)th row.
5) Print the first column from bottom to top of the matrix i.e from row ‘rows’ to ‘R’, print the elements of the Cth column.
6) Call the function recursively with the updated values of boundaries, spiralPrint(matrix, R + 1, C + 1, rows - 1, cols - 1).

TC : O(N*M) , where N = number of rows and M = number of columns of the matrix.
SC : O(max(N,M))

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

To make an AI less repetitive in a long paragraph, you should increase:

Choose another skill to practice
Similar interview experiences
company logo
SDE - Intern
4 rounds | 3 problems
Interviewed by JP Morgan
1775 views
0 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 5 problems
Interviewed by JP Morgan
1279 views
0 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 4 problems
Interviewed by JP Morgan
1024 views
0 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 3 problems
Interviewed by JP Morgan
1016 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - Intern
3 rounds | 6 problems
Interviewed by Amazon
15448 views
4 comments
0 upvotes
company logo
SDE - Intern
4 rounds | 7 problems
Interviewed by Microsoft
15308 views
1 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Amazon
10120 views
2 comments
0 upvotes