Add office photos
JPMorgan Chase & Co. logo
Engaged Employer

JPMorgan Chase & Co.

Verified
4.0
based on 6.2k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Software Developer
Skills
Clear (1)

30+ JPMorgan Chase & Co. Software Developer Interview Questions and Answers

Updated 24 Jun 2024

Q1. 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

Q2. 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

Q3. 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

Q4. 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.

Find the maximum number of beautiful substrings that a binary string can be split into.

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

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

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

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

Q5. 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

Q6. 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
Are these interview questions helpful?

Q7. 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

Q8. 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
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. 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 maintain the order of recently used keys.

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

  • Update the order of keys in the linked list on get and put operations.

  • Evict the least recently used key when the cache reaches its capacity.

  • Handle edge cases like key not found in cache.

  • Example: put(1,1), put(2,2), put(3,3), put(4,...read more

Add your answer
right arrow

Q10. 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

Q11. 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

Q12. 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

Q13. 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.

  • Iterate through intervals and merge overlapping ones

  • Sort merged intervals based on starting times

  • Handle edge cases like empty input or single interval

  • Example: Input - [[1,4], [3,5], [6,8], [10,12], [8,9]], Output - [[1,5], [6,9], [10,12]]

Add your answer
right arrow

Q14. 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

Q15. 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

Q16. 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

Q17. 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
Q18. 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
Q19. 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
Q20. 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

Q21. 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
Q22. 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
Q23. 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

Q24. 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
Q25. 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
Q26. 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

Q27. How to monitor heap memory area? And how objects are removed from heap memory

Ans.

Heap memory can be monitored using tools like profilers. Objects are removed from heap memory through garbage collection.

  • Use profilers like VisualVM or Java Mission Control to monitor heap memory usage

  • Analyze heap dumps to identify memory leaks and optimize memory usage

  • Garbage collection automatically removes unreferenced objects from heap memory

  • Different garbage collection algorithms like Mark and Sweep, Copying, and Generational are used

  • Tuning garbage collection parameters ...read more

Add your answer
right arrow

Q28. Can you design a load balancer which can handle multiple addition of new instances or pods?

Ans.

Yes, a load balancer can handle multiple addition of new instances or pods.

  • A load balancer distributes incoming traffic across multiple instances or pods.

  • To handle multiple additions, the load balancer should be able to dynamically update its routing configuration.

  • Load balancers can use various algorithms to distribute traffic, such as round-robin, least connections, or weighted distribution.

  • Load balancers can also perform health checks on instances or pods to ensure they are...read more

Add your answer
right arrow

Q29. Can you design a distributed system which can handle load of 1M requests per second?

Ans.

Yes, a distributed system can handle 1M requests per second by using load balancing, horizontal scaling, and caching.

  • Implement load balancing to distribute incoming requests across multiple servers.

  • Use horizontal scaling by adding more servers to handle the increased load.

  • Implement caching to store frequently accessed data and reduce the load on the backend.

  • Optimize the system by using efficient algorithms and data structures.

  • Ensure fault tolerance and high availability by re...read more

Add your answer
right arrow
Q30. What are virtual destructors in C++?
Ans.

Virtual destructors in C++ are used to ensure that the correct destructor is called when deleting an object through a base class pointer.

  • Virtual destructors are declared with the 'virtual' keyword in the base class to allow proper cleanup of derived class objects.

  • When deleting an object through a base class pointer, having a virtual destructor ensures that the destructor of the derived class is called.

  • Without a virtual destructor, only the base class destructor would be calle...read more

Add your answer
right arrow

Q31. Tell me about memory allocation (stack vs. heap)?

Ans.

Memory allocation refers to the process of assigning memory to programs during runtime.

  • Stack allocation is done automatically and is limited in size.

  • Heap allocation is done manually and is larger in size.

  • Stack memory is used for local variables and function calls.

  • Heap memory is used for dynamic memory allocation.

  • Memory leaks can occur if heap memory is not properly managed.

Add your answer
right arrow

Q32. How to handle an application running on different instances?

Ans.

Handling an application running on different instances involves load balancing, monitoring, and synchronization.

  • Implement load balancing to distribute the workload evenly across instances.

  • Monitor the performance and health of each instance to ensure optimal operation.

  • Use synchronization techniques to maintain consistency and avoid conflicts between instances.

  • Implement failover mechanisms to handle instances going offline or becoming unresponsive.

  • Consider using containerizatio...read more

Add your answer
right arrow

Q33. How to implements caching in your application?

Ans.

Caching improves application performance by storing frequently accessed data in memory.

  • Identify the data that needs to be cached

  • Choose a caching strategy (e.g., in-memory cache, distributed cache)

  • Implement caching logic in the application code

  • Set appropriate cache expiration policies

  • Handle cache invalidation when data changes

Add your answer
right arrow

Q34. Print a matrix in spiral order?

Ans.

Printing a matrix in spiral order

  • Start from the first element and print it

  • Move in a spiral order towards the center of the matrix

  • Repeat until all elements are printed

Add your answer
right arrow

Q35. Find substrings from a list program in Python

Ans.

Use list comprehension to find substrings in a list of strings in Python

  • Use list comprehension to iterate through the list of strings

  • Use the 'in' keyword to check if the substring is present in each string

  • Filter out strings that do not contain the substring

Add your answer
right arrow

Q36. SOLID principles and explain all of them

Ans.

SOLID principles are a set of five design principles for writing maintainable and scalable code.

  • Single Responsibility Principle (SRP) - A class should have only one reason to change.

  • Open/Closed Principle (OCP) - A class should be open for extension but closed for modification.

  • Liskov Substitution Principle (LSP) - Subtypes should be substitutable for their base types.

  • Interface Segregation Principle (ISP) - A client should not be forced to depend on methods it does not use.

  • Depe...read more

Add your answer
right arrow

Q37. Logging System explanations about splunk

Ans.

Splunk is a powerful logging system used for collecting, indexing, and analyzing machine-generated data.

  • Splunk is used for real-time monitoring, searching, and analyzing log data from various sources.

  • It can be used to troubleshoot issues, monitor system performance, and detect security threats.

  • Splunk allows users to create custom dashboards and reports for visualizing data insights.

  • It supports a wide range of data sources including logs, metrics, and events.

  • Splunk can be inte...read more

Add your answer
right arrow

Q38. Microservices Architecture explanation

Ans.

Microservices architecture is an approach to software development where a single application is composed of small, independent services that communicate with each other through APIs.

  • Each service is responsible for a specific function or feature of the application

  • Services are loosely coupled, allowing for easier scalability and maintenance

  • Communication between services is typically done through lightweight protocols like HTTP or messaging queues

  • Microservices can be deployed in...read more

Add your answer
right arrow

Q39. Hashmap vs linked hashmap

Ans.

Hashmap allows null values and keys, while LinkedHashMap maintains insertion order.

  • Hashmap does not maintain insertion order, while LinkedHashMap maintains insertion order.

  • LinkedHashMap extends HashMap class and adds a doubly-linked list to maintain insertion order.

  • Hashmap allows null values and keys, while LinkedHashMap does not allow null keys but allows null values.

  • Hashmap is generally faster than LinkedHashMap for most operations.

  • Use Hashmap when order is not important, a...read more

Add your answer
right arrow

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. Software Developer

based on 24 interviews
4 Interview rounds
Coding Test Round
Technical Round
HR Round - 1
HR Round - 2
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

Intuit Logo
3.5
 • 46 Interview Questions
Coforge Logo
3.3
 • 14 Interview Questions
Mphasis Logo
3.4
 • 13 Interview Questions
View all
Recently Viewed
LIST OF COMPANIES
Credit Bajaar
Overview
PHOTOS
InsuranceDekho
3 office photos
SALARIES
Amazon Development Centre India
SALARIES
Amazon Development Centre India
No Salaries
INTERVIEWS
Amazon Development Centre India
No Interviews
SALARIES
Amazon Development Centre India
INTERVIEWS
ICICI Prudential Life Insurance
No Interviews
SALARIES
Amazon Development Centre India
INTERVIEWS
Aparna Constructions and Estates
No Interviews
CAMPUS PLACEMENT
IPS Academy, Indore
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter