Tip 1 : Prepare all standard DSA questions from GFG very well. Be thorough with everything mentioned in your resume since the interviewer can ask anything. Avoid writing things you do not know.
Tip 2 :Have 2-3 good projects and in-depth knowledge about the same. Be prepared to explain your project in detail and answer any follow-up questions.
Tip 3 : Prepare the question you would ask your interviewer beforehand. This is an excellent chance to make a good impression. Do not lose your calm and be confident. The interviewers are very friendly and help you if you get stuck somewhere.
Tip 1 : Mention at least two projects on your resume. Having both projects from different domains is a plus point. For example, I had one project on machine learning and another one was a web development project.
Tip 2 : Only mention the things you are confident about. Do not lie on resume and prepare each and every point on resume thoroughly.
It was around 6 pm and was held on Hackerrank. Having switched on WebCam during the entire duration was mandatory. We were required to solve 2 questions under 65 mins. Solving one problem completely, along with some of the test cases of another, was enough for getting shortlisted.
If two words have the same length then the word which comes first in 'TEXT' also comes first in the rearranged sentence.
Step 1 : Remove the capital letter (first letter of the sentence) and the full stop at the end.
Step 2 : I made use of the C++ STL library. I made a pair of strings and int where the string is the word and int is the position of the word in the sentence. These pairs were stored in a vector. I sorted the vector using the sort function of C++ STL and utilizing a custom comparison function to arrange the pairs according to string.length and if string.length was equal, arrange according to the second element of the pair.
Step 3 : The sorted vector contains the order of words in the sentence. Join all the words and capitalize the first letter and add full stop.
1. Each of the digits 1 - 9 must occur exactly once in each row.
2. Each of the digits 1 - 9 must occur exactly once in each column.
3. Each of the digits 1 - 9 must occur exactly once in each of the 9, 3 x 3 sub-matrices of the matrix.
1. There will always be a cell in the matrix which is empty.
2. The given initial matrix will always be consistent according to the rules mentioned in the problem statement.
I followed the backtracking approach. This is a common problem.
The interview started with my brief introduction, and the interviewer then proceeded to ask some questions. I was asked to write a code for these two questions:
1. Find the distances between two given nodes of a binary tree.
2. Find the next greater number with the same set of digits.
After I was able to solve both questions, he proceeded to ask some questions about my projects. He seemed interested in the ML project and asked some basic questions regarding the same. We had a brief discussion on how Machine learning can be used in the Chemical Engineering field. He asked me why I was aspiring to become a software engineer despite having a Chemical engineering background. The round ended with me asking him about the types of projects interns are provided to work on at JPMC
I used the Least common ancestors to do this question.
D(a,b) = D(a,LCA) + D(b,LCA) where
D(a,b) is the min distance between node a and node b.
LCA is the Least Common Ancestor is a common tree problem.
If the given string is 56789, then the next greater number is 56798. Note that although 56790 is also greater than the given number it contains 1 '0' which is not in the original number and also it does not contain the digit '8'.
The given string is non-empty.
If the answer does not exist, then return -1.
The given number does not contain any leading zeros.
My approach was to traverse the given number from rightmost digit, and keep traversing till I found a digit which is smaller than the previously traversed digit.
This round was comparatively short. It also started with my brief introduction. The interviewer then asked me about my area of interest, which was Data Structure and Algorithms. He asked me how to find the Nth node from the end in a linked list using a single traversal and LRU Cache implementation. He also seemed interested in the ML Project and asked to explain it in brief. He then gave me a situation wherein I had to make a model for a self-driving car. I gave him a basic idea of how the model will be trained, and he was satisfied. The round ended with him asking generic questions like 'Why JPMC?' , 'Why I chose to code despite belonging to the non-CSE background.'
Input : 1 -> 2 -> 3 -> 4 -> 'NULL' and 'K' = 2
Output: 1 -> 2 -> 4 -> 'NULL'
Explanation:
After removing the second node from the end, the linked list become 1 -> 2 -> 4 -> 'NULL'.
I used the concept of two pointers. Make two pointers namely fast and slow. Move the fast pointer by n steps while keeping the slow pointer at the head. Now keep on incrementing both pointers till fast one reaches the end. The slow pointer is now at the nth Node from End.
1. get(key) - Return the value of the key if the key exists in the cache, otherwise return -1.
2. put(key, value), Insert the value in the cache if the key is not already present or update the value of the given key if the key is already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting the new item.
Type 0: for get(key) operation.
Type 1: for put(key, value) operation.
1. The cache is initialized with a capacity (the maximum number of unique keys it can hold at a time).
2. Access to an item or key is defined as a get or a put operation on the key. The least recently used key is the one with the oldest access time.
This is a standard question from queues. I knew this beforehand so I answered the LRU cache Implementation can be done by using queue and hash map to store the pointer to element. Interviewer was satisfied.
It was late at night (around 12:30 am) but was crisp and short. HR was really friendly. I was called for the HR round on the same day as the other two rounds. HR asked me why I chose JPMC and why I aspire to become a software engineer. He then asked me about my skill set and how I will enhance it if I got selected. He then asked if I had any questions for him, where I asked him how the virtual working environment has been different from the office experience at JPMC, and if there were any significant challenges.
Why I chose JPMC and why I aspire to become a software engineer?
How I will enhance my skill set if I was selected?
Tip 1 : Prepare some generic HR Questions in advance to give you an edge.
Tip 2 : Be confident about your answers and do not take too much time to think of an answer.