Add office photos
JPMorgan Chase & Co. logo
Engaged Employer

JPMorgan Chase & Co.

Verified
4.0
based on 6.1k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

400+ JPMorgan Chase & Co. Interview Questions and Answers

Updated 25 Feb 2025
Popular Designations

Q1. A rat has 3000 gm of rice, he has to travel a distance of 3000m, he eats 1gm rice/m, his maximum carrying capcity is 1000 gm,how should he travel the distance to reach with maximum rice left

Ans.

A rat with 3000gm rice, 3000m distance, 1gm rice/m, 1000gm capacity. How to reach with max rice left?

  • The rat should carry maximum rice possible in the beginning

  • The rat should eat rice only when necessary

  • The rat should carry rice in intervals to avoid exhaustion

  • The rat should calculate the amount of rice needed for the journey

  • The rat should prioritize reaching the destination over carrying excess rice

View 4 more answers
right arrow

Q2. Split Binary String Problem Statement

Chintu has a long binary string str. A binary string is a string that contains only 0 and 1. He considers a string to be 'beautiful' if and only if the number of 0's and 1'...read more

Ans.

The task is to split a binary string into beautiful substrings with equal number of 0's and 1's.

  • Count the number of 0's and 1's in the string.

  • Iterate through the string and split it into beautiful substrings whenever the count of 0's and 1's becomes equal.

  • Return the maximum number of beautiful substrings that can be formed.

  • If it is not possible to split the string into beautiful substrings, return -1.

View 1 answer
right arrow
JPMorgan Chase & Co. Interview Questions and Answers for Freshers
illustration image

Q3. There are 8 bottles of milk out of which one bottle is poisoned. What will be the minimum number of persons required to find the poisoned bottle if the person dies within 24 hours of drinking the poison. You ha...

read more
Ans.

Minimum number of persons required to find the poisoned milk bottle out of 8 bottles within 24 hours.

  • Divide the bottles into groups of 3 and label them A, B, C.

  • Give each person a different combination of groups to taste.

  • If someone dies, the poisoned bottle is in that group.

  • If no one dies, the poisoned bottle is in group D.

  • Repeat the process with the bottles in the identified group.

View 5 more answers
right arrow

Q4. Rahul And Minimum Subarray Problem Statement

Rahul is mastering arrays. He is tasked to find the length of the smallest contiguous subarray in a given array/list ARR of size N, such that its sum exceeds a speci...read more

Ans.

Find the length of the smallest subarray in a given array whose sum exceeds a specified value.

  • Iterate through the array while keeping track of the sum of the current subarray.

  • Use two pointers to maintain a sliding window approach to find the smallest subarray.

  • Update the minimum length of the subarray whenever the sum exceeds the specified value.

  • Return the length of the smallest subarray found.

  • Handle cases where no subarray exists with sum exceeding the specified value.

Add your answer
right arrow
Discover JPMorgan Chase & Co. interview dos and don'ts from real experiences

Q5. Merge Overlapping Intervals Problem Statement

Given a specified number of intervals, where each interval is represented by two integers denoting its boundaries, the task is to merge all overlapping intervals an...read more

Ans.

Merge overlapping intervals and return sorted list of merged intervals.

  • Identify overlapping intervals based on start and end times

  • Merge overlapping intervals to form new intervals

  • Sort the merged intervals in ascending order of start times

Add your answer
right arrow

Q6. Minimum Travel Cost Problem

You are given a country called 'Ninjaland' with 'N' states, numbered from 1 to 'N'. These states are connected by 'M' bidirectional roads, each with a specified travel cost. The aim ...read more

Ans.

Find the minimum cost selection of roads to travel to every state in a country.

  • Create a graph representation of the states and roads with their costs.

  • Use a minimum spanning tree algorithm like Kruskal's or Prim's to find the optimal roads.

  • Select 'N' - 1 roads with the lowest costs to cover all states.

  • Return the selected roads and their costs as output.

Add your answer
right arrow
Are these interview questions helpful?

Q7. Reverse Words in a String: Problem Statement

You are given a string of length N. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more

Ans.

Reverse words in a string while handling leading, trailing, and multiple spaces.

  • Split the input string by spaces to get individual words

  • Reverse the order of the words

  • Join the reversed words with a single space in between

Add your answer
right arrow

Q8. Excel Column Number Conversion

Given a column title as it appears in an Excel sheet, your task is to return its corresponding column number.

Example:

Input:
S = "AB"
Output:
28
Explanation:

The sequence is as f...read more

Ans.

Convert Excel column title to corresponding column number.

  • Iterate through the characters in the input string from right to left

  • Calculate the corresponding value of each character based on its position and multiply by 26^position

  • Sum up all the values to get the final column number

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. How will you perform pre-fix and post-fix operation for the given string expression?

Ans.

Pre-fix and post-fix operations can be performed on a string expression using appropriate operators.

  • Pre-fix operation involves placing the operator before the operand in the expression.

  • Post-fix operation involves placing the operator after the operand in the expression.

  • Examples of pre-fix operators include ++, --, !, and ~.

  • Examples of post-fix operators include ++ and --.

View 2 more answers
right arrow

Q10. Next Greater Element Problem Statement

You are given an array arr of length N. For each element in the array, find the next greater element (NGE) that appears to the right. If there is no such greater element, ...read more

Ans.

The task is to find the next greater element for each element in an array to its right, if no greater element exists, return -1.

  • Iterate through the array from right to left and use a stack to keep track of elements.

  • Pop elements from the stack until a greater element is found or the stack is empty.

  • Store the next greater element for each element in the output array.

Add your answer
right arrow

Q11. Left View of a Binary Tree Problem Statement

Given a binary tree, your task is to print the left view of the tree.

Example:

Input:
The input will be in level order form, with node values separated by a space. U...read more
Ans.

Print the left view of a binary tree given in level order form.

  • Traverse the tree level by level and print the first node of each level (leftmost node).

  • Use a queue to keep track of nodes at each level.

  • Time complexity should be O(n) where n is the number of nodes in the tree.

Add your answer
right arrow

Q12. LRU Cache Design Question

Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:

1. get(key) - Return the value of the key if it exists in the cache; otherwise, re...read more

Ans.

Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraint.

  • Implement a doubly linked list to keep track of the order of keys based on their recent usage.

  • Use a hashmap to store key-value pairs for quick access and updates.

  • When capacity is reached, evict the least recently used item before inserting a new item.

  • Update the order of keys in the linked list whenever a key is accessed or updated.

Add your answer
right arrow

Q13. A new software has 3 functions SelectSum(), log() and exp(). You have a table of 1000 data points, how will you find product of all points using only the above mentioned functions

Ans.

To find the product of all data points using SelectSum(), log(), and exp() functions.

  • Use the log() function to convert the product into a sum of logarithms

  • Apply the SelectSum() function to calculate the sum of logarithms

  • Finally, use the exp() function to convert the sum back into the product

Add your answer
right arrow

Q14. Write an algorithm to select the number between min and maximum from a number series and that number shouldn't be a multiple of 10

Ans.

Algorithm to select a non-multiple of 10 from a number series between min and max

  • Loop through the number series from min to max

  • Check if the current number is a multiple of 10

  • If not, select the number and exit the loop

  • If all numbers are multiples of 10, return an error message

View 2 more answers
right arrow

Q15. Make Array Elements Equal Problem Statement

Given an integer array, your objective is to change all elements to the same value, minimizing the cost. The cost of changing an element from x to y is defined as |x ...read more

Ans.

Find the minimum cost to make all elements of an array equal by changing them to a common value.

  • Calculate the median of the array and find the sum of absolute differences between each element and the median.

  • Sort the array and find the median element, then calculate the sum of absolute differences between each element and the median.

  • If the array has an even number of elements, consider the average of the two middle elements as the median.

Add your answer
right arrow

Q16. Count Subarrays with Sum Divisible by K

Given an array ARR and an integer K, your task is to count all subarrays whose sum is divisible by the given integer K.

Input:

The first line of input contains an integer...read more
Ans.

Count subarrays with sum divisible by K in an array.

  • Iterate through the array and keep track of prefix sum modulo K.

  • Use a hashmap to store the frequency of prefix sum remainders.

  • For each prefix sum remainder, count the number of subarrays that sum up to a multiple of K.

  • Handle cases where the prefix sum itself is divisible by K.

  • Return the total count of subarrays with sum divisible by K.

Add your answer
right arrow

Q17. How will you find loop in the circular linked list?

Ans.

Loop in a circular linked list can be found using Floyd's cycle-finding algorithm.

  • Initialize two pointers, slow and fast, both pointing to the head of the linked list.

  • Move slow pointer by one node and fast pointer by two nodes in each iteration.

  • If there is a loop, both pointers will eventually meet at some point.

  • If there is no loop, fast pointer will reach the end of the linked list.

  • Time complexity of this algorithm is O(n) and space complexity is O(1).

View 1 answer
right arrow

Q18. Longest Increasing Path in Matrix Problem Statement

Given a 2-D matrix mat with 'N' rows and 'M' columns, where each element at position (i, j) is mat[i][j], determine the length of the longest increasing path ...read more

Ans.

The problem involves finding the length of the longest increasing path in a 2-D matrix starting from a given cell.

  • Create a recursive function to explore all possible paths from a cell to its neighboring cells.

  • Use memoization to avoid redundant calculations and improve efficiency.

  • Keep track of the length of the longest increasing path found so far.

  • Consider edge cases such as when the matrix is empty or when there are no increasing paths.

  • Test the solution with different input m...read more

Add your answer
right arrow

Q19. Find Permutation Problem Statement

Given an integer N, determine an array of size 2 * N that satisfies the following conditions:

  1. Each number from 1 to N appears exactly twice in the array.
  2. The distance between...read more
Ans.

The task is to find a permutation array of size 2*N with specific conditions.

  • Create an array of size 2*N to store the permutation.

  • Ensure each number from 1 to N appears exactly twice in the array.

  • Check that the distance between the second and first occurrence of each number is equal to the number itself.

  • Return the array if conditions are met, else return an empty array.

Add your answer
right arrow

Q20. Maximum Number by One Swap

You are provided with an array of N integers representing the digits of a number. You are allowed to perform an operation where you can swap the values at two different indices to for...read more

Ans.

Given an array of integers representing digits of a number, swap two values to form the maximum possible number.

  • Iterate through the array to find the maximum digit.

  • Swap the maximum digit with the first digit if it is not already at the first position.

  • Handle cases where there are multiple occurrences of the maximum digit.

View 1 answer
right arrow

Q21. Subset Sum Equal To K Problem Statement

Given an array/list of positive integers and an integer K, determine if there exists a subset whose sum equals K.

Provide true if such a subset exists, otherwise return f...read more

Ans.

Given an array of positive integers and an integer K, determine if there exists a subset whose sum equals K.

  • Use dynamic programming to solve this problem efficiently

  • Create a 2D array to store if a subset sum is possible for each element and target sum

  • Iterate through the array and update the 2D array based on current element and target sum

  • Check if the last element of the 2D array is true for the given target sum

View 1 answer
right arrow

Q22. Divide Linked List Into Two Problem Statement

You have been given a singly linked list of integers. Your task is to divide this list into two smaller singly linked lists wherein the nodes appear in an alternati...read more

Ans.

Divide a singly linked list into two smaller lists with nodes appearing in an alternating fashion.

  • Iterate through the original linked list and assign nodes alternatively to the two smaller lists.

  • Handle cases where creating either of the sub-lists is impossible by returning an empty list.

  • Ensure to properly terminate the linked lists with -1 at the end of each list.

  • Consider the constraints provided while implementing the solution.

  • Test the solution with multiple test cases to va...read more

Add your answer
right arrow

Q23. Top View of Binary Tree

Given a binary tree of integers, the task is to return the top view of the given binary tree. The top view of the binary tree is the set of nodes visible when viewed from the top.

Input:...read more

Ans.

Return the top view of a binary tree given in level-order format.

  • Use a map to store the horizontal distance of each node from the root

  • Perform a level-order traversal and keep track of the horizontal distance of each node

  • For each horizontal distance, store the node value if it is the first node encountered at that distance

Add your answer
right arrow

Q24. Rectangle Counting on an N x N Chessboard

Given a positive integer N, determine the number of possible rectangles that can be formed on an N x N chessboard, excluding squares.

Input:

The first line contains an ...read more
Ans.

Count the number of rectangles (excluding squares) that can be formed on an N x N chessboard.

  • Calculate total rectangles using formula N*(N+1)*M*(M+1)/4 where M = N-1

  • Subtract the number of squares (N*(N+1)*(2*N+1)/6) from total rectangles

  • Return the count modulo 1000000007 for each test case

Add your answer
right arrow

Q25. Shortest Path in a Binary Matrix Problem Statement

Given a binary matrix of size N * M where each element is either 0 or 1, find the shortest path from a source cell to a destination cell, consisting only of 1s...read more

Ans.

Find the shortest path in a binary matrix from a source cell to a destination cell consisting only of 1s.

  • Use Breadth First Search (BFS) algorithm to find the shortest path.

  • Keep track of visited cells to avoid revisiting them.

  • Update the path length as you traverse the matrix.

  • Return -1 if no valid path exists.

Add your answer
right arrow

Q26. Optimal Strategy for a Coin Game

You are playing a coin game with your friend Ninjax. There are N coins placed in a straight line.

Here are the rules of the game:

1. Each coin has a value associated with it.
2....read more
Add your answer
right arrow

Q27. Spiral Matrix Problem Statement

You are given a N x M matrix of integers. Your task is to return the spiral path of the matrix elements.

Input

The first line contains an integer 'T' which denotes the number of ...read more
Ans.

The task is to return the spiral path of elements in a given matrix.

  • Iterate through the matrix in a spiral path by adjusting the boundaries at each step.

  • Keep track of the direction of traversal (right, down, left, up) to cover all elements.

  • Handle edge cases such as when the matrix is a single row or column.

  • Implement the spiral path traversal algorithm efficiently to meet the time limit.

  • Ensure to print the elements in the correct order as per the spiral path.

Add your answer
right arrow

Q28. Intersection of Linked List Problem

You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.

Your task is to determine the data...read more

Ans.

Find the node where two linked lists merge.

  • Traverse both lists to find their lengths and the difference in lengths

  • Move the pointer of the longer list by the difference in lengths

  • Move both pointers simultaneously until they meet at the merging point

Add your answer
right arrow

Q29. Pair Sum Problem Statement

You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.

Note:

Each pa...read more

Ans.

Find pairs of elements in an array that sum up to a given value, sorted in a specific order.

  • Iterate through the array and for each element, check if the complement (S - current element) exists in a hash set.

  • If the complement exists, add the pair to the result list.

  • Sort the result list based on the criteria mentioned in the question.

  • Return the sorted list of pairs.

Add your answer
right arrow

Q30. Sudoku Solver Problem Statement

You are provided with a 9x9 2D integer matrix MAT representing a Sudoku puzzle. The empty cells in the Sudoku are denoted by zeros, while the other cells contain integers from 1 ...read more

Ans.

Implement a function to solve a Sudoku puzzle by filling empty cells with valid numbers.

  • Iterate through each empty cell and try filling it with a valid number (1-9) that satisfies Sudoku rules.

  • Use backtracking to backtrack and try different numbers if a cell cannot be filled with a valid number.

  • Check rows, columns, and 3x3 sub-grids to ensure each digit appears only once.

  • Recursively solve the puzzle until all empty cells are filled with valid numbers.

Add your answer
right arrow

Q31. Chocolate Bar Problem Statement

You are given a chocolate bar represented as a grid with dimensions N x M. Your task is to cut the chocolate bar, either horizontally or vertically, to obtain exactly 'K' pieces....read more

Add your answer
right arrow

Q32. What are the different types of risks associated with a bond?

Ans.

Different types of risks associated with a bond

  • Interest rate risk - changes in interest rates affect bond prices

  • Credit risk - risk of default by the issuer

  • Inflation risk - risk of loss of purchasing power due to inflation

  • Liquidity risk - risk of not being able to sell the bond when needed

  • Call risk - risk of the issuer calling back the bond before maturity

  • Reinvestment risk - risk of not being able to reinvest the coupon payments at the same rate

  • Currency risk - risk of changes ...read more

Add your answer
right arrow

Q33. Pascal's Triangle Construction

You are provided with an integer 'N'. Your task is to generate a 2-D list representing Pascal’s triangle up to the 'N'th row.

Pascal's triangle is a triangular array where each el...read more

Add your answer
right arrow

Q34. Write the algorithm for reversing the string

Ans.

The algorithm reverses a given string.

  • Iterate through the string from the last character to the first character.

  • Append each character to a new string or an array in reverse order.

  • Return the reversed string or array.

View 3 more answers
right arrow

Q35. Pattern Matching Problem Statement

Given a pattern as a string and a set of words, determine if the pattern and the words list align in the same sequence.

Input:
T (number of test cases)
For each test case:
patte...read more
Ans.

Given a pattern and a list of words, determine if the words align with the pattern.

  • Create a mapping between characters in the pattern and words in the list.

  • Check if the mapping preserves the order of characters in the pattern.

  • Return 'True' if the sequence of words matches the order of characters in the pattern, else return 'False'.

Add your answer
right arrow

Q36. Find Minimum Depth of Binary Tree

You are given a Binary Tree of integers. Your task is to determine the minimum depth of this Binary Tree. The minimum depth is defined as the number of nodes along the shortest...read more

Add your answer
right arrow

Q37. Shortest Path in an Unweighted Graph

The city of Ninjaland is represented as an unweighted graph with houses and roads. There are 'N' houses numbered 1 to 'N', connected by 'M' bidirectional roads. A road conne...read more

Add your answer
right arrow

Q38. Counting Pairs Problem Statement

Given a positive integer N, determine the count of all possible positive integral pairs (X, Y) that satisfy the equation 1/X + 1/Y = 1/N.

Example:

Input:
T = 1
N = 2
Output:
3
Ex...read more
Add your answer
right arrow

Q39. Rearrange Words in a Sentence

You are provided with a sentence 'TEXT'. Each word in the sentence is separated by a single space, and the sentence starts with a capital letter. Your task is to rearrange the word...read more

Ans.

Rearrange words in a sentence based on increasing order of their length.

  • Split the sentence into words and calculate the length of each word.

  • Sort the words based on their lengths in increasing order.

  • If two words have the same length, maintain their original order from the input sentence.

Add your answer
right arrow

Q40. Fastest Horse Problem Statement

Given ‘N’ horses running in separate lanes, each horse's finish time is provided in an array. You are tasked to process 'Q' queries. For each query, determine the time taken by t...read more

Ans.

Given finish times of horses, determine fastest horse in specified lane ranges for multiple queries.

  • Iterate through each query and find the minimum finish time within the specified range of horses.

  • Use a nested loop to handle multiple test cases and queries efficiently.

  • Ensure to handle edge cases like empty ranges or invalid inputs.

  • Consider using a data structure like arrays to store finish times and process queries.

Add your answer
right arrow

Q41. Sudoku Validity Problem Statement

You are provided with a 9 x 9 2D matrix MATRIX containing digits (1-9) and empty cells indicated by 0.

Your task is to determine if there exists a method to fill all empty cell...read more

Ans.

Check if a valid Sudoku solution exists for a given 9x9 matrix with empty cells.

  • Iterate through each row, column, and sub-matrix to ensure all digits from 1 to 9 appear exactly once.

  • Use sets to keep track of digits seen in each row, column, and sub-matrix.

  • If any digit is repeated in a row, column, or sub-matrix, return 'no'.

  • If all rows, columns, and sub-matrices pass the validity check, return 'yes'.

Add your answer
right arrow

Q42. Paths in a Matrix Problem Statement

Given an 'M x N' matrix, print all the possible paths from the top-left corner to the bottom-right corner. You can only move either right (from (i,j) to (i,j+1)) or down (fro...read more

Ans.

Find all possible paths from top-left to bottom-right in a matrix by moving only right or down.

  • Use backtracking to explore all possible paths from top-left to bottom-right in the matrix

  • At each cell, recursively explore moving right and down until reaching the bottom-right corner

  • Keep track of the current path and add it to the result when reaching the destination

Add your answer
right arrow

Q43. How do you handle custom exceptions in your current project ?

Ans.

I handle custom exceptions by creating my own exception classes and throwing them when necessary.

  • I create custom exception classes that extend the built-in Exception class

  • I throw these exceptions when specific errors occur in my code

  • I catch these exceptions in a try-catch block and handle them appropriately

  • I include helpful error messages in my custom exceptions to aid in debugging

Add your answer
right arrow

Q44. Kth Largest Number Problem Statement

You are given a continuous stream of numbers, and the task is to determine the kth largest number at any moment during the stream.

Explanation:

A specialized data structure ...read more

Ans.

Design a data structure to find the kth largest number in a continuous stream of integers.

  • Design a specialized data structure to handle continuous stream of numbers

  • Implement add(DATA) function to add integers to the pool

  • Implement getKthLargest() function to retrieve the kth largest number

  • Maintain the pool of numbers and update it based on queries

  • Output the kth largest number for each Type 2 query

Add your answer
right arrow
Q45. What is a lambda expression in Java, and how does it relate to a functional interface?
Ans.

Lambda expression in Java is a concise way to represent a method implementation. It is related to functional interfaces by providing a single abstract method implementation.

  • Lambda expressions allow you to write concise code by providing a way to represent a method implementation in a more compact form.

  • Functional interfaces are interfaces with a single abstract method. Lambda expressions can be used to provide the implementation for this single method.

  • For example, a functional...read more

Add your answer
right arrow
Q46. What is the difference between the Thread class and the Runnable interface when creating a thread in Java?
Ans.

Thread class is a class in Java that extends the Thread class, while Runnable interface is an interface that implements the run() method.

  • Thread class extends the Thread class, while Runnable interface implements the run() method.

  • A class can only extend one class, so using Runnable interface allows for more flexibility in the class hierarchy.

  • Using Runnable interface separates the task from the thread, promoting better design practices.

  • Example: Thread t = new Thread(new MyRunna...read more

Add your answer
right arrow

Q47. Arithmetic Progression Queries Problem Statement

Given an integer array ARR of size N, perform the following operations:

- update(l, r, val): Add (val + i) to arr[l + i] for all 0 ≤ i ≤ r - l.

- rangeSum(l, r):...read more

Ans.

Implement update and rangeSum operations on an integer array based on given queries.

  • Implement update(l, r, val) by adding (val + i) to arr[l + i] for all i in range (0, r - l).

  • Implement rangeSum(l, r) to return the sum of elements in the array from index l to r.

  • Handle queries using 1-based indexing.

  • Ensure constraints are met for input values.

  • Output the sum of arr[l..r] for each rangeSum operation.

Add your answer
right arrow

Q48. If I buy a piece of equipment, walk me through the impact on the 3 financial statements

Ans.

Buying equipment affects all 3 financial statements

  • On the income statement, the purchase will be recorded as an expense, reducing net income

  • On the balance sheet, the equipment will be recorded as an asset, increasing total assets

  • On the cash flow statement, the purchase will be recorded as a cash outflow from investing activities

Add your answer
right arrow

Q49. Sort Elements by Frequency

Your task is to sort a list of repeated integers by their frequency in decreasing order. The element with the highest frequency should appear first. If two elements have the same freq...read more

Add your answer
right arrow

Q50. Distance Between Two Nodes in a Binary Tree

Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more

Ans.

Calculate the distance between two nodes in a binary tree.

  • Traverse the tree to find the paths from the root to each node

  • Find the lowest common ancestor of the two nodes

  • Calculate the distance by adding the distances from the LCA to each node

Add your answer
right arrow

Q51. Next Greater Number Problem Statement

Given a string S which represents a number, determine the smallest number strictly greater than the original number composed of the same digits. Each digit's frequency from...read more

Ans.

The task is to find the smallest number greater than the given number with the same set of digits.

  • Iterate from right to left to find the first digit that can be swapped with a smaller digit to make the number greater.

  • Swap this digit with the smallest digit to its right that is greater than it.

  • Sort all digits to the right of the swapped digit in ascending order to get the smallest number greater than the original.

  • If no such number exists, return -1.

  • Example: For input '56789', ...read more

Add your answer
right arrow
Q52. What do you understand by autowiring in Spring Boot, and can you name the different modes of it?
Ans.

Autowiring in Spring Boot is a feature that allows Spring to automatically inject dependencies into a Spring bean.

  • Autowiring eliminates the need for explicit bean wiring in the Spring configuration file.

  • There are different modes of autowiring in Spring Boot: 'byName', 'byType', 'constructor', 'autodetect', and 'no'.

  • For example, in 'byName' mode, Spring looks for a bean with the same name as the property that needs to be autowired.

Add your answer
right arrow
Q53. What is the probability of obtaining a sum of 22 or more when four dice are thrown?
Ans.

The probability of obtaining a sum of 22 or more when four dice are thrown.

  • Calculate the total number of outcomes when four dice are thrown.

  • Determine the number of outcomes where the sum is 22 or more.

  • Divide the favorable outcomes by the total outcomes to get the probability.

  • Use combinations and permutations to calculate the probabilities.

Add your answer
right arrow

Q54. Merge Intervals Problem Statement

You are provided with 'N' intervals, each containing two integers denoting the start time and end time of the interval.

Your task is to merge all overlapping intervals and retu...read more

Ans.

Merge overlapping intervals and return sorted list by start time.

  • Sort the intervals based on start time.

  • Iterate through intervals and merge overlapping ones.

  • Return the merged intervals sorted by start time.

Add your answer
right arrow

Q55. Count Distinct Substrings

You are provided with a string S. Your task is to determine and return the number of distinct substrings, including the empty substring, of this given string. Implement the solution us...read more

Ans.

Implement a function to count the number of distinct substrings in a given string using a trie data structure.

  • Create a trie data structure to store the substrings of the input string.

  • Traverse the trie to count the number of distinct substrings.

  • Handle empty string as a distinct substring.

  • Return the count of distinct substrings for each test case.

Add your answer
right arrow

Q56. Problem: Sort an Array of 0s, 1s, and 2s

Given an array/list ARR consisting of integers where each element is either 0, 1, or 2, your task is to sort this array in increasing order.

Input:

The input starts with...read more
Ans.

Sort an array of 0s, 1s, and 2s in increasing order.

  • Use a three-pointer approach to sort the array in a single pass.

  • Initialize three pointers for 0, 1, and 2 values and iterate through the array.

  • Swap elements based on the values encountered to achieve the sorted array.

Add your answer
right arrow

Q57. Most Frequent Non-Banned Word Problem Statement

Given a paragraph consisting of letters in both lowercase and uppercase, spaces, and punctuation, along with a list of banned words, your task is to find the most...read more

Ans.

Find the most frequent word in a paragraph that is not in the list of banned words.

  • Split the paragraph into words and convert them to uppercase for case-insensitivity.

  • Count the frequency of each word, excluding banned words.

  • Return the word with the highest frequency in uppercase.

Add your answer
right arrow

Q58. Count Subarrays with Given XOR Problem Statement

You are given an array of integers ARR and an integer X. Your task is to determine the number of subarrays of ARR whose bitwise XOR is equal to X.

Example:

Input...read more
Ans.

Count the number of subarrays in an array whose XOR is equal to a given value.

  • Iterate through the array and keep track of XOR values and their frequencies using a hashmap.

  • For each element, calculate the XOR with the previous elements to find subarrays with XOR equal to the given value.

  • Use the hashmap to efficiently count the number of subarrays with the desired XOR value.

  • Handle edge cases like XOR value being 0 separately.

  • Time complexity can be optimized to O(N) using a hashm...read more

Add your answer
right arrow

Q59. Stack using Two Queues Problem Statement

Develop a Stack Data Structure to store integer values using two Queues internally.

Your stack implementation should provide these public functions:

Explanation:

1. Cons...read more
Ans.

Implement a stack using two queues to store integer values with specified functions.

  • Use two queues to simulate stack operations efficiently.

  • Maintain the top element in one of the queues for easy access.

  • Ensure proper handling of edge cases like empty stack or invalid operations.

  • Example: Push elements 5, 10, 15; Pop element 15; Check top element 10; Check size of stack; Check if stack is empty.

Add your answer
right arrow

Q60. Explain endpoints in your microservice. What request they send and why?

Ans.

Endpoints in microservices are responsible for handling incoming requests and sending responses.

  • Endpoints are the entry points for a microservice

  • They handle incoming requests and send responses

  • Endpoints can be HTTP endpoints, message queue endpoints, or event-driven endpoints

  • Examples of endpoints include RESTful APIs, SOAP APIs, and GraphQL APIs

Add your answer
right arrow

Q61. what is 'Big data'? Why is it called 'Big'

Ans.

Big data refers to large and complex data sets that cannot be processed using traditional data processing methods.

  • Big data is characterized by its volume, velocity, and variety

  • It is used in various industries such as healthcare, finance, and retail

  • Examples of big data include social media data, sensor data, and transactional data

  • It is called 'big' because it involves processing massive amounts of data

  • Big data requires specialized tools and technologies for processing and anal...read more

Add your answer
right arrow

Q62. Remove the Kth Node from the End of a Linked List

You are given a singly Linked List with 'N' nodes containing integer data and an integer 'K'. Your task is to delete the Kth node from the end of this Linked Li...read more

Ans.

Implement a function to remove the Kth node from the end of a singly linked list.

  • Traverse the list to find the length 'N' of the linked list.

  • Calculate the position of the node to be removed from the beginning as 'N - K + 1'.

  • Traverse the list again and remove the node at the calculated position.

Add your answer
right arrow

Q63. LRU Cache Problem Statement

Design and implement a data structure for the Least Recently Used (LRU) Cache to efficiently support the following operations:

  1. get(key): Retrieve the value of the key if it exists i...read more
Ans.

Design and implement a data structure for LRU Cache to efficiently support get and put operations.

  • Implement a doubly linked list to maintain the order of recently used keys.

  • Use a hashmap to store key-value pairs for quick access.

  • Update the linked list and hashmap accordingly for get and put operations.

  • Discard the least recently used item when the cache reaches its capacity.

  • Handle edge cases like key not found in cache.

  • Example: Initialize cache with capacity 3, perform get and...read more

Add your answer
right arrow

Q64. Populating Next Right Pointers in Each Node

Given a complete binary tree with 'N' nodes, your task is to determine the 'next' node immediately to the right in level order for each node in the given tree.

Input:...read more

Ans.

Implement a function to populate next right pointers in a complete binary tree.

  • Traverse the tree level by level using BFS

  • For each node, set its next pointer to the next node in the same level

  • Handle null nodes appropriately by setting next pointer to null

  • Ensure the tree is a complete binary tree to guarantee correct output

Add your answer
right arrow

Q65. Longest Palindromic Substring Problem Statement

You are provided with a string STR of length N. The goal is to identify the longest palindromic substring within this string. In cases where multiple palindromic ...read more

Ans.

Given a string, find the longest palindromic substring, choosing the one with the smallest start index if multiple exist.

  • Iterate through the string and expand around each character to find palindromes

  • Keep track of the longest palindrome found and its starting index

  • Return the longest palindromic substring with the smallest start index

Add your answer
right arrow

Q66. Merge Two Sorted Linked Lists Problem Statement

You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.

Input:...read more

Ans.

Merge two sorted linked lists into a single sorted linked list without using additional space.

  • Create a dummy node to start the merged list

  • Compare the values of the two linked lists and append the smaller value to the merged list

  • Move the pointer of the merged list and the pointer of the smaller value's linked list

  • Continue this process until one of the linked lists is fully traversed

  • Append the remaining elements of the other linked list to the merged list

Add your answer
right arrow
Q67. What are the start() and run() methods of the Thread class in Java?
Ans.

The start() method is used to start a new thread, while the run() method contains the code that will be executed by the thread.

  • start() method is used to start a new thread and calls the run() method internally

  • run() method contains the code that will be executed by the thread

  • It is recommended to override the run() method with the desired functionality

Add your answer
right arrow
Q68. What is meant by inheritance in object-oriented programming?
Ans.

Inheritance in OOP allows a class to inherit properties and behaviors from another class.

  • Inheritance allows for code reusability by creating a new class based on an existing class.

  • The new class (subclass) can access all the properties and methods of the existing class (superclass).

  • Example: A 'Car' class can inherit from a 'Vehicle' class, gaining attributes like 'speed' and methods like 'drive'.

Add your answer
right arrow
Q69. Can you explain the SOLID principles in Object-Oriented Design?
Ans.

SOLID principles are a set of five design principles in object-oriented programming to make software designs more understandable, flexible, and maintainable.

  • S - Single Responsibility Principle: A class should have only one reason to change.

  • O - Open/Closed Principle: Software entities should be open for extension but closed for modification.

  • L - Liskov Substitution Principle: Objects of a superclass should be replaceable with objects of its subclasses without affecting the func...read more

Add your answer
right arrow
Q70. What is the difference between an abstract class and an interface in OOP?
Ans.

Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.

  • Abstract class can have constructor, fields, and methods, while interface cannot have any implementation.

  • A class can only extend one abstract class, but can implement multiple interfaces.

  • Abstract classes are used to define common behavior among subclasses, while interfaces are used to define a contract for classes to implement.

  • Example: Abstract class 'Animal' with ab...read more

Add your answer
right arrow
Q71. What is the main difference between UNION and UNION ALL?
Ans.

UNION combines and removes duplicates, UNION ALL combines without removing duplicates.

  • UNION removes duplicates, UNION ALL does not

  • UNION is slower than UNION ALL as it has to check for duplicates

  • UNION is used when you want to combine and remove duplicates, UNION ALL is used when you want to combine without removing duplicates

Add your answer
right arrow

Q72. With O(1) time complexity, find out if the given number is missing, from the given numbers between 1 to 100 where more than 2 numbers are missing.

Ans.

To find a missing number from 1 to 100 with O(1) time complexity.

  • Use the formula n(n+1)/2 to find the sum of numbers from 1 to 100.

  • Subtract the sum of given numbers from the sum of all numbers to find the missing number.

  • Use a hash table to keep track of the given numbers and check for missing numbers in O(1) time.

View 2 more answers
right arrow

Q73. What is compliance and different compliance measures maintained

Ans.

Compliance refers to adhering to laws, regulations, and standards set by governing bodies.

  • Compliance measures ensure that organizations operate within legal and ethical boundaries

  • Examples of compliance measures include HIPAA, GDPR, PCI DSS, and SOX

  • Compliance can be achieved through policies, procedures, training, audits, and assessments

  • Non-compliance can result in legal and financial penalties, damage to reputation, and loss of business

Add your answer
right arrow
Q74. What does the @SpringBootApplication annotation do internally?
Ans.

The @SpringBootApplication annotation is used to mark the main class of a Spring Boot application.

  • It is a combination of @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations.

  • It tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.

  • It is often placed on the main class that contains the main method to bootstrap the Spring Boot application.

Add your answer
right arrow
Q75. What are the basic annotations that Spring Boot offers?
Ans.

Spring Boot offers basic annotations like @SpringBootApplication, @RestController, @Autowired, @RequestMapping, @Component, @Service, @Repository.

  • @SpringBootApplication - Used to mark the main class of a Spring Boot application.

  • @RestController - Used to define a RESTful controller.

  • @Autowired - Used for automatic dependency injection.

  • @RequestMapping - Used to map web requests to specific handler methods.

  • @Component - Used to indicate a class is a Spring component.

  • @Service - Use...read more

Add your answer
right arrow

Q76. What is the most complex algorithm you've ever written?

Ans.

I am an AI language model and do not have the ability to write algorithms.

  • As an AI language model, I am not capable of writing algorithms.

  • However, I can assist in generating code snippets or providing guidance on algorithmic concepts.

  • Feel free to ask me any questions related to algorithms or programming in general.

Add your answer
right arrow

Q77. What is the difference between multi tasking, multi processing and multi programming operating systems with examples ?

Ans.

Multi tasking, multi processing, and multi programming are different approaches to managing tasks in an operating system.

  • Multi tasking allows multiple tasks to run concurrently on a single processor.

  • Multi processing involves multiple processors running tasks simultaneously.

  • Multi programming allows multiple programs to be loaded into memory and executed concurrently.

  • Examples of multi tasking operating systems include Windows, macOS, and Linux.

  • Examples of multi processing opera...read more

Add your answer
right arrow
Q78. What is the difference between a clustered index and a non-clustered index?
Ans.

Clustered index determines the physical order of data in a table, while non-clustered index has a separate structure.

  • Clustered index determines the physical order of data in a table

  • Non-clustered index has a separate structure that includes a copy of the indexed columns and a pointer to the actual data

  • A table can have only one clustered index, but multiple non-clustered indexes

  • Clustered index is faster for retrieving large ranges of data, while non-clustered index is faster fo...read more

Add your answer
right arrow
Q79. What is the difference between 'git pull' and 'git fetch'?
Ans.

Git pull combines git fetch and git merge, while git fetch only downloads new data from a remote repository.

  • Git pull is used to update the local branch with the latest changes from the remote repository.

  • Git fetch only downloads new data from the remote repository, but does not integrate it into the local branch.

  • Git pull is a combination of git fetch and git merge commands.

  • Git fetch is useful to see what changes have been made in the remote repository before merging them into ...read more

Add your answer
right arrow
Q80. What are the different methods of session management in Servlets?
Ans.

Different methods of session management in Servlet

  • Cookies

  • URL Rewriting

  • Hidden Form Fields

  • Session Tracking API

  • HTTP Session

Add your answer
right arrow
Q81. How can you print numbers from 1 to 100 using more than two threads in an optimized approach?
Ans.

Use multiple threads to print numbers from 1 to 100 in an optimized approach.

  • Divide the range of numbers (1-100) among the threads to avoid overlap.

  • Use synchronization mechanisms like mutex or semaphore to ensure orderly printing.

  • Consider using a shared variable to keep track of the current number being printed.

Add your answer
right arrow
Q82. What is the difference between a constructor and a method in Object-Oriented Programming?
Ans.

Constructor is a special method used to initialize objects, while a method is a function that performs a specific task.

  • Constructor is called automatically when an object is created, while a method is called explicitly by the programmer.

  • Constructors have the same name as the class, while methods have unique names.

  • Constructors do not have a return type, while methods have a return type.

  • Constructors are used to set initial values of object properties, while methods are used to p...read more

Add your answer
right arrow
Q83. How can you optimize the loading of website assets?
Ans.

Optimize website assets loading by minimizing file sizes, leveraging caching, and using asynchronous loading.

  • Minimize file sizes by compressing images, minifying CSS and JavaScript files

  • Leverage caching by setting appropriate cache headers and using a content delivery network (CDN)

  • Use asynchronous loading techniques such as lazy loading, deferred loading, and async/defer attributes

  • Combine and bundle multiple files to reduce the number of requests

  • Optimize the order of loading ...read more

Add your answer
right arrow

Q84. Any coding done in curriculum, explain the most complex one

Ans.

Yes, I have coded in curriculum. The most complex one was a project on building a web application using React and Node.js.

  • Built a full-stack web application using React and Node.js

  • Implemented user authentication and authorization using JSON Web Tokens (JWT)

  • Used MongoDB as the database and Mongoose as the ODM

  • Implemented real-time updates using Socket.IO

  • Deployed the application on Heroku

  • Handled errors and implemented logging using Winston

Add your answer
right arrow
Q85. What are the new tags for media elements introduced in HTML5?
Ans.

New tags in Media Elements in HTML5 include <audio> and <video>.

  • <audio> tag for audio content

  • <video> tag for video content

  • Attributes like controls, autoplay, loop, etc. can be used with these tags

Add your answer
right arrow

Q86. Will duration be greater for a fixed rate bond or a floating rate bond?

Ans.

Duration will be greater for a fixed rate bond.

  • Fixed rate bonds have a longer duration than floating rate bonds.

  • Duration is the measure of a bond's sensitivity to interest rate changes.

  • Fixed rate bonds have a fixed interest rate, so their duration is longer as they are more sensitive to interest rate changes.

Add your answer
right arrow

Q87. Explain how the balance sheet works for banking sector

Ans.

The balance sheet for banking sector shows the assets, liabilities and equity of the bank at a specific point in time.

  • Assets include cash, loans, investments, and property

  • Liabilities include deposits, loans from other banks, and bonds

  • Equity includes the bank's capital and reserves

  • The balance sheet must balance, with assets equaling liabilities plus equity

  • The balance sheet is used to analyze the financial health of the bank

View 1 answer
right arrow
Q88. How does Spring Boot work?
Ans.

Spring Boot is a framework that simplifies the development of Java applications by providing default configurations and dependencies.

  • Spring Boot eliminates the need for manual configuration by providing sensible defaults.

  • It uses an embedded server, such as Tomcat or Jetty, to run the application.

  • Spring Boot automatically configures the application based on the dependencies added to the project.

  • It promotes convention over configuration, reducing boilerplate code.

  • Spring Boot su...read more

Add your answer
right arrow
Q89. What is CORS in MVC and how does it work?
Ans.

CORS in MVC is Cross-Origin Resource Sharing, a mechanism that allows restricted resources on a web page to be requested from another domain.

  • CORS is a security feature implemented in web browsers to prevent cross-origin requests by default.

  • It works by adding specific HTTP headers to the server's response, indicating which origins are allowed to access the resources.

  • In MVC, CORS can be configured using the 'EnableCors' attribute on controllers or by configuring it in the 'Web....read more

Add your answer
right arrow
Q90. What are the advantages of web services?
Ans.

Web services offer advantages such as interoperability, scalability, reusability, and platform independence.

  • Interoperability: Web services allow different applications to communicate and share data regardless of the programming languages or platforms they are built on.

  • Scalability: Web services can handle a large number of requests and can be easily scaled up or down to meet changing demands.

  • Reusability: Web services promote code reuse as they can be accessed by multiple appli...read more

Add your answer
right arrow

Q91. What caused the 2008 financial crisis?

Ans.

The 2008 financial crisis was caused by a combination of factors including subprime mortgages, risky investments, and lack of regulation.

  • Subprime mortgages were given to borrowers who were not creditworthy and could not afford to repay the loans.

  • These mortgages were then bundled together and sold as securities to investors, who were not aware of the high risk involved.

  • Investment banks also made risky investments and used excessive leverage, which led to their collapse.

  • The lac...read more

Add your answer
right arrow

Q92. What is hashmap? Where it is used? What is the time complexity to implement it?

Ans.

HashMap is a data structure that stores key-value pairs and provides constant time complexity for basic operations.

  • HashMap is used to store and retrieve data based on unique keys.

  • It is commonly used in programming languages to implement associative arrays or dictionaries.

  • The time complexity to implement a HashMap is O(1) for basic operations like insertion, deletion, and retrieval.

Add your answer
right arrow

Q93. You have two threads one printing even numbers in order and other odd numbers. Design an algorithm so that it prints numbers in natural order?

Ans.

Use a shared variable and synchronization mechanisms to ensure natural order printing of numbers.

  • Create two threads, one for printing even numbers and the other for printing odd numbers.

  • Use a shared variable to keep track of the current number to be printed.

  • Implement synchronization mechanisms like locks or semaphores to ensure only one thread can access the shared variable at a time.

  • Each thread should check if it is its turn to print the number based on the parity of the cur...read more

Add your answer
right arrow

Q94. 50 red marbles, 50 blue marbles. 2 jars in a room. Divide the marbles into the 2 jars such that you maximise the probability that a blind man picks up a red marble

Ans.

To maximize the probability of picking a red marble, divide the marbles unevenly, with more red marbles in one jar.

  • Place 49 red marbles and 1 blue marble in one jar, and the remaining 1 red marble and 49 blue marbles in the other jar.

  • This way, the blind man has a higher chance of picking the jar with 49 red marbles and 1 blue marble.

  • The probability of picking a red marble from the first jar is 49/50, while from the second jar it is 1/50.

View 1 answer
right arrow

Q95. What is the probability that three unbiased dices to roll such that a&gt;b&gt;c. Extrapolate to five random number generators (1 to n)

Ans.

Probability of rolling three unbiased dices such that a>b>c and extrapolating to five random number generators.

  • The probability of rolling three unbiased dices such that a>b>c is 1/216.

  • To extrapolate to five random number generators, we need to calculate the probability of generating five random numbers such that the first is greater than the second, the second is greater than the third, and so on.

  • The probability of generating five random numbers such that the first is greater...read more

Add your answer
right arrow

Q96. Is data quality more important or is timeliness?

Ans.

Both data quality and timeliness are important, but it depends on the specific use case.

  • Data quality is crucial for decision-making and analysis, as inaccurate data can lead to incorrect conclusions.

  • Timeliness is important for real-time decision-making and time-sensitive operations.

  • In some cases, data quality may be more important, such as in medical research where accuracy is critical.

  • In other cases, timeliness may be more important, such as in financial trading where split-...read more

Add your answer
right arrow

Q97. Where transactional can be used in microservices ?

Ans.

Transactional can be used in microservices to ensure data consistency and integrity.

  • Transactional mechanisms can be used to ensure that all microservices involved in a transaction either commit or rollback together.

  • Transactional boundaries can be defined to ensure that all data changes within a transaction are atomic and consistent.

  • Transactional messaging can be used to ensure that messages are delivered exactly once and in the correct order.

  • Examples of transactional systems ...read more

Add your answer
right arrow
Q98. What is meant by multitasking and multithreading in operating systems?
Ans.

Multitasking refers to the ability of an operating system to run multiple tasks concurrently, while multithreading involves executing multiple threads within a single process.

  • Multitasking allows multiple processes to run simultaneously on a single processor, switching between them quickly.

  • Multithreading enables a single process to execute multiple threads concurrently, sharing resources like memory and CPU time.

  • Multitasking is at the process level, while multithreading is at ...read more

Add your answer
right arrow
Q99. What do you mean by virtual functions in C++?
Ans.

Virtual functions in C++ allow a function to be overridden in a derived class, enabling polymorphic behavior.

  • Virtual functions are declared in a base class with the 'virtual' keyword.

  • They are intended to be overridden in derived classes to provide specific implementations.

  • When a virtual function is called through a base class pointer or reference, the actual function to be called is determined at runtime based on the object's type.

  • Example: class Shape { virtual void draw() { ...read more

Add your answer
right arrow
Q100. Write a Java 8 program to iterate through a Stream using the forEach method.
Ans.

A Java 8 program to iterate a Stream using the forEach method.

  • Create a Stream object from a collection or array

  • Use the forEach method to perform an action on each element of the Stream

  • The action can be a lambda expression or a method reference

Add your answer
right arrow
1
2
3
4
5
Next

More about working at JPMorgan Chase & Co.

Back
Awards Leaf
AmbitionBox Logo
Top Rated Mega Company - 2024
Awards Leaf
Awards Leaf
AmbitionBox Logo
Top Rated Company for Women - 2024
Awards Leaf
Awards Leaf
AmbitionBox Logo
Top Rated Financial Services Company - 2024
Awards Leaf
HQ - New York, New York, United States (USA)
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at JPMorgan Chase & Co.

based on 582 interviews
Interview experience
4.1
Good
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

Bharti Airtel Logo
4.0
 • 376 Interview Questions
CGI Group Logo
4.0
 • 362 Interview Questions
Goldman Sachs Logo
3.5
 • 346 Interview Questions
Standard Chartered Logo
3.7
 • 169 Interview Questions
Cybage Logo
3.8
 • 167 Interview Questions
John Deere Logo
4.1
 • 141 Interview Questions
View all
Top JPMorgan Chase & Co. Interview Questions And Answers
Share an Interview