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

SDE - Intern

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

Interview preparation journey

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

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

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

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

Interview rounds

01
Round
Medium
Online Coding Test
Duration90 Minutes
Interview date23 Aug 2018
Coding problem2

This was an online coding round where we had 2 questions of Medium to Hard level of difficulty to solve under 90 minutes. I was able to solve the 2nd question fully and the 1st one partially. 10 students were shortlisted for further rounds and I was one of them.

1. Longest Palindromic Substring

Moderate
20m average time
80% success
0/80
Asked in companies
GartnerGoldman SachsQuikr

You are given a string 'str' of length 'N'.


Your task is to return the longest palindromic substring. If there are multiple strings, return any.


A substring is a contiguous segment of a string.


For example :
str = "ababc"

The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome. 

There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
Problem approach

Approach :

1) Create a 2-D dp boolean vector(with all false initially) where dp[i][j] states whether s[i...j] is a palindrome or not and
initilialise a variable ans=1 which will store the final answer.

2) Base Case : For every i from 0 to n-1 fill dp[i][i]=1 ( as a single character is always a palindrome ) .

3) Now, run 2 loops first one from i=n-1 to i=0 (i.e., tarverse from the back of the string) and the second one from
j=i+1 to n .

4) For every s[i]==s[j] , check if(j-i==1 i.e., if s[i] and s[ j] are two consecutive same letters) or if(dp[i+1][j-1]==1 or not
i.e., if the string s[i+1,....j-1] is palindrome or not .

5) Because if the string s[i+1,....j-1] is a palindrome and s[i]==s[j] then s[i] and s[j] can be appended at the starting
and the ending position of s[i+1,...j-1] and s[i...j] will then be a palindrome , so mark dp[i][j]=1 and update the answer
as ans=max(ans , j-i+1).

6) Finally return the ans


TC : O(N^2) where N=length of the string s
SC : O(N^2)

Try solving now

2. Count Subarrays with Given XOR

Moderate
15m average time
85% success
0/80
Asked in companies
UberArcesiumHCL Technologies

Given an array of integers ‘ARR’ and an integer ‘X’, you are supposed to find the number of subarrays of 'ARR' which have bitwise XOR of the elements equal to 'X'.

Note:
An array ‘B’ is a subarray of an array ‘A’ if ‘B’ that can be obtained by deletion of, several elements(possibly none) from the start of ‘A’ and several elements(possibly none) from the end of ‘A’. 
Problem approach

Approach (Using Hashing) :

1) Create a HashMap “prefXor” which stores the count of subarrays having a particular XOR value.

2) Create a variable “curXor” which stores the XOR for ‘i’ elements. Initialise it with zero. Also, create a
variable called “ans” to store the count of the subarrays having XOR ‘X’.

3) Start iterating through given array/list using a variable ‘i’ such that 0 <= ‘i’ < n

3.1) Update the “curXor” i.e. curXor = curXor ^ arr[i]

3.2) Store the required value of the prefix Xor to make the XOR of the subarray ending at the current
index equal to X i.e. req = X ^ curXor

3.3) Now add the count of prefix arrays with required xor i.e. ans = ans + prefXor[req]

3.4) Update the “prefXor” HashMap with the “curXor” i.e. prefXor[curXor] = prefXor[curXor] + 1


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

Try solving now
02
Round
Medium
Face to Face
Duration70 Minutes
Interview date23 Aug 2018
Coding problem3

This was a preety intense round where I had to solve 3 algorithmic questions under 70 minutes. I first explained my approach for each of these questions and also discussed why they were optimal in the first place with their respective time and space compleixities. The interviewer was quite impressed at the end of the round.

1. Kth Largest Number

Moderate
30m average time
65% success
0/80
Asked in companies
Goldman SachsPhonePeAmazon

You will be given a stream of numbers, and you need to find the 'kth' largest number in the stream at any given time.


As the stream of numbers can not be given during compile time, so you need to design a data structure which can accept infinite numbers and can return the 'kth' largest number at any given time.


The stream of numbers is nothing but a large collection of numbers from which integers are read at runtime, such as the user will never know the upper limit on the number of integers that will be read.


The implemented data structure must support the following operations:

1. add(DATA) :
   This function should take one argument of type and store it in its pool and returns the 'kth' largest number from the current pool of integers.

You will be given 'q' queries:

val - For this query, insert the integer into your current pool of integers and return the 'kth' largest integer from the existing pool of integers.
Note
 1. The maximum number of integers that will be given will always be under memory limits.

 2. You will also be given an initial pool of integers whose size equals k.

 3. The maximum number of queries will be less than 10^5.

 4. The 'kth' largest element is not the 'kth' distinct element but the 'kth' largest element in the sorted order.

 5. There will be at least one query of type 2.
Problem approach

Naive Solution:

Keep an array of size k. The idea is to keep the array sorted increasing order so that the k'th largest element can be
found in O(1) time.

How to process a new element of stream?

For every new element in stream, check if the new element is smaller than current k'th largest element. If yes, then
ignore it. If no, then remove the smallest element from array and insert new element in sorted order. Time complexity
of processing a new element becomes O(k).



Efficient Solution:

Use Min Heap of size k to store k largest elements of stream. Thr k'th largest element is always at root and can be
found in O(1) time.

How to process a new element of stream?

Compare the new element with root of heap. If new element is smaller, then ignore it. Otherwise replace root with
new element and call heapify for the root of modified heap.

Try solving now

2. Merge Two Sorted Linked Lists

Moderate
15m average time
80% success
0/80
Asked in companies
AmazonAppleGoldman Sachs

You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.

Note:

The given linked lists may or may not be null.

For example:

If the first list is: 1 -> 4 -> 5 -> NULL and the second list is: 2 -> 3 -> 5 -> NULL

The final list would be: 1 -> 2 -> 3 -> 4 -> 5 -> 5 -> NULL
Problem approach

Approach :

1) Compare the head of both linked lists.

2) Find the smaller node among the two head nodes. The current element will be the smaller node among two head
nodes.

3) The rest elements of both lists will appear after that.

4) Now run a recursive function with parameters, the next node of the smaller element, and the other head.

5) The recursive function will return the next smaller element linked with rest of the sorted element. Now point the
next of current element to that, i.e curr_ele->next=recursivefunction()

6) Handle some corner cases.
6.1) If both the heads are NULL return null.
6.2) If one head is null return the other.


TC : O(N), where N=number of nodes in the Linked List
SC : O(N)

Try solving now

3. Stack using queue

Moderate
25m average time
65% success
0/80
Asked in companies
PhilipsAmazonAccenture

Implement a Stack Data Structure specifically to store integer data using two Queues.


There should be two data members, both being Queues to store the data internally. You may use the inbuilt Queue.


Implement the following public functions :

1. Constructor:
It initializes the data members(queues) as required.

2. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.

3. pop() :
It pops the element from the top of the stack and, in turn, returns the element being popped or deleted. In case the stack is empty, it returns -1.

4. top :
It returns the element being kept at the top of the stack. In case the stack is empty, it returns -1.

5. size() :
It returns the size of the stack at any given instance of time.

6. isEmpty() :
It returns a boolean value indicating whether the stack is empty or not.
Operations Performed on the Stack:
Query-1(Denoted by an integer 1): Pushes an integer data to the stack. (push function)

Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack and returns it to the caller. (pop function)

Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack but doesn't remove it, unlike the pop function. (top function)

Query-4(Denoted by an integer 4): Returns the current size of the stack. (size function)

Query-5(Denoted by an integer 5): Returns a boolean value denoting whether the stack is empty or not. (isEmpty function)
Example
Operations: 
1 5
1 10
2
3
4

Enqueue operation 1 5: We insert 5 at the back of the queue.
  Queue: [5]

Enqueue operation 1 10: We insert 10 at the back of the queue.
  Queue: [5, 10]

Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
  Output: 5
  Queue: [10]

Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
  Output: 10
  Queue: [10]

IsEmpty operation 4: We check if the queue is empty.
  Output: False
  Queue: [10]
Problem approach

Approach : A stack can be implemented using two queues. Let stack to be implemented be ‘s’ and queues used to
implement be ‘q1’ and ‘q2’. Stack ‘s’ can be implemented in two ways :

Method 1 (push - O(1) , pop - O(n) ) :

1) push(s, x) operation :
i) Enqueue x to q1 (assuming size of q1 is unlimited).

2) pop(s) operation :
i) One by one dequeue everything except the last element from q1 and enqueue to q2.
ii) Dequeue the last item of q1, the dequeued item is result, store it.
iii) Swap the names of q1 and q2
iv) Return the item stored in step 2.


TC : push(s,x) -> O(1)
pop() -> O(n)


Method 2 (push - O(n) , pop - O(1) ) :

1) push(s, x) operation :
i) Enqueue x to q2
ii) One by one dequeue everything from q1 and enqueue to q2.
iii) Swap the names of q1 and q2

2) pop(s) operation :
i) Dequeue an item from q1 and return it.


TC : push(s,x) -> O(n)
pop() -> O(1)

Try solving now
03
Round
Easy
HR Round
Duration30 Minutes
Interview date23 Aug 2018
Coding problem2

This was a typical HR round with some standard Behavioral questions.

1. Basic HR Question

Tell me something about yourself?

Problem approach

Tip 1 : Prepare the points that you will speak in your introduction prior to the interview.
Tip 2 : Tell about your current cgpa, achievements and authenticated certification
Tip 3 : I told about my role in current internship and what all I do

2. Basic HR Question

Do you know anything about the company ?

Problem approach

General Tip : Before an interview for any company , have a breif insight about the company , what it does , when was
it founded and so on . All these info can be easily acquired from the Company Website itself.

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
3 rounds | 5 problems
Interviewed by JP Morgan
1279 views
0 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 5 problems
Interviewed by JP Morgan
0 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
15447 views
4 comments
0 upvotes
company logo
SDE - Intern
4 rounds | 7 problems
Interviewed by Microsoft
15307 views
1 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Amazon
10120 views
2 comments
0 upvotes