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

SDE - 1

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

Interview preparation journey

expand-icon
Journey
First, I was selected for a Tier 1 college, and that's where my coding journey began. I did most of my coding in my final years, but I regret that I didn't start earlier.
Application story
I applied for a software developer position when the company visited my campus for placements. After submitting my resume through the campus portal, I completed pre-interview assessments that focused on showcasing my technical skills.
Why selected/rejected for the role?
I was rejected for this offer because I did not perform well in all the rounds of the interview process.
Preparation
Duration: 8 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1: Practice topic-wise questions from the basics.

Tip 2: Watch system design mock interviews.

Tip 3: Do mock interviews with friends for DSA and system design rounds.

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

Tip 1: Include some projects on your resume.
Tip 2: Do not include false information on your resume.

Interview rounds

01
Round
Medium
Video Call
Duration60 minutes
Interview date27 Jul 2024
Coding problem2

1. Convert binary tree to mirror tree

Easy
15m average time
85% success
0/40
Asked in companies
AdobeWalmartThales

Given a binary tree, convert this binary tree into its mirror tree.

A binary tree is a tree in which each parent node has at most two children.

Mirror of a Tree: Mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all non-leaf nodes interchanged.

alt text

Note:
1. Make in-place changes, that is, modify the nodes given a binary tree to get the required mirror tree.
Problem approach

The idea is to traverse recursively and swap the right and left subtrees after traversing the subtrees.

Follow the steps below to solve the problem:

Call Mirror for left-subtree i.e., Mirror(left-subtree)
Call Mirror for right-subtree i.e., Mirror(right-subtree)
Swap left and right subtrees.
temp = left-subtree
left-subtree = right-subtree
right-subtree = temp

Try solving now

2. Palindrome Partitioning

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

You are given a string 'S'. Your task is to partition 'S' such that every substring of the partition is a palindrome. You need to return all possible palindrome partitioning of 'S'.

Note: A substring is a contiguous segment of a string.

For Example:
For a given string “BaaB”
3 possible palindrome partitioning of the given string are:
{“B”, “a”, “a”, “B”}
{“B”, “aa”, “B”}
{“BaaB”}
Every substring of all the above partitions of “BaaB” is a palindrome.
Problem approach

The problem can be solved by 

1) finding the suffix starting from j and ending at index i, (1 <= j <= i <= n – 1), which are palindromes. 
2) we can make a cut here that requires 1 + min cut from the rest substring [0, j – 1]. 
3) For all such palindromic suffixes starting at j and ending at i, keep minimising in minCutDp[i]. 
4) Similarly, we need to compute results for all such i. (1 <= i <= n – 1) and 
5) finally, minCutDp[n – 1] will be the minimum number of cuts needed for palindrome partitioning of the given string.

Try solving now
02
Round
Easy
Video Call
Duration60 minutes
Interview date30 Jul 2024
Coding problem2

1. Bottom View Of Binary Tree

Moderate
10m average time
90% success
0/80
Asked in companies
OYOMicrosoftAmazon

You are given a 'Binary Tree'.


Return the bottom view of the binary tree.


Note :
1. A node will be in the bottom-view if it is the bottom-most node at its horizontal distance from the root. 

2. The horizontal distance of the root from itself is 0. The horizontal distance of the right child of the root node is 1 and the horizontal distance of the left child of the root node is -1. 

3. The horizontal distance of node 'n' from root = horizontal distance of its parent from root + 1, if node 'n' is the right child of its parent.

4. The horizontal distance of node 'n' from root = horizontal distance of its parent from the root - 1, if node 'n' is the left child of its parent.

5. If more than one node is at the same horizontal distance and is the bottom-most node for that horizontal distance, including the one which is more towards the right.


Example:
Input: Consider the given Binary Tree:

alt text

Output: 4 2 6 3 7

Explanation:
Below is the bottom view of the binary tree.

alt text

1 is the root node, so its horizontal distance = 0.
Since 2 lies to the left of 0, its horizontal distance = 0-1= -1
3 lies to the right of 0, its horizontal distance = 0+1 = 1
Similarly, horizontal distance of 4 = Horizontal distance of 2 - 1= -1-1=-2
Horizontal distance of 5 = Horizontal distance of 2 + 1=  -1+1 = 0
Horizontal distance of 6 = 1-1 =0
Horizontal distance of 7 = 1+1 = 2

The bottom-most node at a horizontal distance of -2 is 4.
The bottom-most node at a horizontal distance of -1 is 2.
The bottom-most node at a horizontal distance of 0 is 5 and 6. However, 6 is more towards the right, so 6 is included.
The bottom-most node at a horizontal distance of 1 is 3.
The bottom-most node at a horizontal distance of 2 is 7.

Hence, the bottom view would be 4 2 6 3 7


Problem approach

Store tree nodes in a queue for the level order traversal. Start with the horizontal distance hd as 0 of the root node, Using a Map that stores key-value pairs sorted by key and keep on adding a left child to the queue along with the horizontal distance as hd-1 and the right child as hd+1.

Every time a new horizontal distance or an existing horizontal distance is encountered put the node data for the horizontal distance as the key. For the first time, it will add it to the map, next time it will replace the value. This will make sure that the bottom-most element for that horizontal distance is present on the map and if you see the tree from beneath that you will see that element. At last traverse the keys of the map and print their respective values.

Try solving now

2. Anagram Pairs

Moderate
30m average time
60% success
0/80
Asked in companies
JP MorganNearbuyTata Consultancy Services (TCS)

You are given two strings 'str1' and 'str1'.


You have to tell whether these strings form an anagram pair or not.


The strings form an anagram pair if the letters of one string can be rearranged to form another string.

Pre-requisites:

Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams. 

Other examples include:

'triangle' and 'integral'
'listen' and 'silent'
Note:
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct. 
Problem approach

I simply used hashing to solve this problem by checking the frequency of characters in both strings.

Try solving now
03
Round
Easy
Video Call
Duration60 minutes
Interview date31 Jul 2024
Coding problem1

1. Flatten Binary Tree to Linked List

Moderate
25m average time
70% success
0/80
Asked in companies
JP MorganChegg Inc.MakeMyTrip

You are given a binary tree consisting of 'n' nodes.


Convert the given binary tree into a linked list where the linked list nodes follow the same order as the pre-order traversal of the given binary tree.


Use the right pointer of the binary tree as the “next” pointer for the linked list and set the left pointer to NULL.


Use these nodes only. Do not create extra nodes.


Example :
Input: Let the binary be as shown in the figure:

Example Tree

Output: Linked List: 15 -> 40 -> 62 -> 10 -> 20 -> NULL

Explanation: As shown in the figure, the right child of every node points to the next node, while the left node points to null.

Also, the nodes are in the same order as the pre-order traversal of the binary tree.
Problem approach

You are given a binary tree consisting of integer values. Your task is to convert the given binary tree into a linked list where the nodes of the linked list follow the same order as the pre-order traversal of the given binary tree.

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 - 1
3 rounds | 4 problems
Interviewed by JP Morgan
0 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 5 problems
Interviewed by JP Morgan
1058 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by JP Morgan
3133 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 2 problems
Interviewed by JP Morgan
3168 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
114453 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57719 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34914 views
7 comments
0 upvotes