PayPal
40+ Mehta Jaising Developers Interview Questions and Answers
Q1. Painting Fences Problem Statement
You are given ‘N’ fences. Your task is to compute the total number of ways to paint these fences using only 2 colors, such that no more than 2 adjacent fences have the same col...read more
Q2. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Q3. Integer to Roman Conversion
Given an integer N
, convert it to its corresponding Roman numeral representation. Roman numerals comprise seven symbols: I, V, X, L, C, D, and M.
Example:
Input:
N = 2
Output:
II
Exp...read more
Q4. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Q5. Cycle Detection in Undirected Graph Problem Statement
You are provided with an undirected graph containing 'N' vertices and 'M' edges. The vertices are numbered from 1 to 'N'. Your objective is to determine whe...read more
Q6. Longest Repeating Subsequence Problem Statement
Given a string st
, your task is to determine the length of the longest repeating subsequence such that no two subsequences have the same character at the same pos...read more
Q7. Painter's Partition Problem
You are given an array/list of length 'N'. Each element of the array/list represents the length of a board. There are 'K' painters available to paint these boards. Each unit of a boa...read more
Q8. Find Magic Index in Sorted Array
Given a sorted array A consisting of N integers, your task is to find the magic index in the given array, where the magic index is defined as an index i such that A[i] = i.
Exam...read more
Q9. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Q10. Palindrome Partitioning II Problem Statement
Given a string ‘str’, find the minimum number of partitions needed such that every segment of the string is a palindrome.
The task is to make cuts in the string to p...read more
Q11. Design a Constant Time Data Structure
Create a data structure that maintains mappings between keys and values, supporting the following operations in constant time:
1. INSERT(key, value): Add or update the inte...read more
Q12. Cycle Detection in a Directed Graph
Determine if a given directed graph contains a cycle. Return true
if at least one cycle is found, otherwise return false
.
Input:
T
The first line consists of the integer T, re...read more
Q13. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
Q14. Total Area of Overlapping Rectangles Problem Statement
Determine the total area covered by two given rectangles on a 2-D coordinate plane, which may have an overlapping area.
Input:
The first line contains an i...read more
Q15. Maximum Difference Problem Statement
Given an array ARR
of N
elements, your task is to find the maximum difference between any two elements in ARR
.
If the maximum difference is even, print EVEN; if it is odd, p...read more
Q16. Sort Linked List Based on Actual Values
Given a Singly Linked List of integers that are sorted based on their absolute values, the task is to sort the linked list based on the actual values.
The absolute value ...read more
Q17. Dijkstra's Shortest Path Problem
Given an undirected graph with ‘V’ vertices (labeled 0, 1, ... , V-1) and ‘E’ edges, where each edge has a weight representing the distance between two connected nodes (X, Y).
Y...read more
Q18. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Q19. DFS Traversal Problem Statement
Given an undirected and disconnected graph G(V, E)
, where V
is the number of vertices and E
is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more
Q21. How would I explain the concept of prime number to an illiterate?
A prime number is a number that is divisible only by 1 and itself.
A prime number has exactly two factors: 1 and itself.
Prime numbers cannot be divided evenly by any other number.
Examples of prime numbers include 2, 3, 5, 7, 11, 13, 17, etc.
Q22. Suggest as many methods as possible for finding the nth largest element in an unsorted linked list
Methods to find nth largest element in an unsorted linked list
Traverse the linked list and store elements in an array, sort the array and return the nth largest element
Use quickselect algorithm to find the nth largest element in O(n) time complexity
Implement a max heap and extract the nth largest element
Divide the linked list into smaller sublists and recursively find the nth largest element
Use merge sort to sort the linked list and return the nth largest element
Q23. what is hashing and how will you implement?
Hashing is a process of converting data into a fixed-size numerical value called a hash code.
Hashing is used to quickly retrieve data from large datasets.
It is commonly used in data structures like hash tables and hash maps.
Hash functions should be fast, deterministic, and produce unique hash codes for different inputs.
Examples of hash functions include MD5, SHA-1, and SHA-256.
Q25. Design classes for educational institutions in a city
Design classes for educational institutions in a city
Identify the main entities: schools, students, teachers, courses
Create a School class with attributes like name, address, and a list of students and teachers
Create a Student class with attributes like name, age, and a list of courses
Create a Teacher class with attributes like name, specialization, and a list of courses
Create a Course class with attributes like name, duration, and a list of students and teachers
Establish rel...read more
Q26. no of pairs between 1 and N satisfy relation pow(a,3)+pow(b,3)=pow(c,3)+pow(d,3).a,b,c,d<=N
The question asks for the number of pairs between 1 and N that satisfy a specific mathematical relation.
The relation is pow(a,3) + pow(b,3) = pow(c,3) + pow(d,3)
The values of a, b, c, and d should be less than or equal to N
Count the number of pairs that satisfy the relation
Q27. find the and return if the given file path existing in the given file hierarcy(file system).
Check if a given file path exists in the file system hierarchy and return the result.
Use file system APIs to check if the given file path exists in the hierarchy.
Traverse the file system hierarchy starting from the root directory to find the given file path.
Return true if the file path exists, false otherwise.
Q28. Show the abstraction and write code for function overriding
Abstraction is hiding the implementation details, function overriding is providing a new implementation for a method in a subclass.
Abstraction involves hiding the complex implementation details and showing only the necessary features to the user.
Function overriding occurs in inheritance when a subclass provides a specific implementation for a method that is already defined in its superclass.
Example: Parent class 'Animal' has a method 'makeSound()', subclass 'Dog' overrides th...read more
Q29. Give a few test cases for a bank transaction
Test cases for a bank transaction
Transaction amount within account balance limit
Transaction amount exceeds account balance limit
Transaction to a valid account number
Transaction to an invalid account number
Transaction with correct transaction code
Transaction with incorrect transaction code
Transaction during bank working hours
Transaction outside bank working hours
Q30. Optimal path cost and path in a matrix . Dynamic programming
Finding optimal path cost and path in a matrix using dynamic programming.
Dynamic programming is a technique to solve problems by breaking them down into smaller subproblems and solving them recursively.
In this case, we can use dynamic programming to find the optimal path cost and path in a matrix.
We can start by defining a 2D array to store the minimum cost of reaching each cell in the matrix.
Then, we can use a recursive function to calculate the minimum cost of reaching the ...read more
Q31. Program to implement Dijkstra’s algorithm
Dijkstra's algorithm finds the shortest path between nodes in a graph.
Create a graph with nodes and edges
Assign a tentative distance to each node
Set the initial node as current and mark it visited
For each neighbor of the current node, calculate the tentative distance
If the tentative distance is less than the current distance, update the distance
Mark the current node as visited and select the unvisited node with the smallest tentative distance
Repeat until the destination node ...read more
Q32. Program to reverse a singly linked list
A program to reverse a singly linked list
Create a new empty linked list
Traverse the original linked list and insert each node at the beginning of the new list
Return the new list
Q33. how to find cycle in graph
To find a cycle in a graph, use depth-first search (DFS) and keep track of visited nodes.
Implement DFS algorithm to traverse the graph
Maintain a visited array to keep track of visited nodes
If a visited node is encountered again during DFS, a cycle exists
Q34. How is MongoDB scalable?
MongoDB is scalable due to its ability to horizontally partition data across multiple servers.
MongoDB uses sharding to distribute data across multiple servers.
Sharding allows for horizontal scaling by adding more servers to the cluster.
MongoDB also supports replica sets for high availability and fault tolerance.
Indexes can be created on any field in a MongoDB document, allowing for efficient querying of large datasets.
Q35. What does Paypal do?
Paypal is a digital payment platform that allows individuals and businesses to make online transactions.
Paypal provides a secure way to send and receive money online.
It allows users to link their bank accounts, credit cards, or debit cards to their Paypal account.
Users can make payments to merchants or individuals using their Paypal balance or linked payment methods.
Paypal offers buyer and seller protection, dispute resolution, and fraud prevention services.
It is widely used ...read more
Q36. Write code for encryption of the code
Encryption of code involves converting plaintext into ciphertext to secure data.
Choose a strong encryption algorithm like AES or RSA
Generate a key for encryption
Encrypt the plaintext using the key and algorithm
Store or transmit the ciphertext securely
Q37. detecting loop in linked list
Detecting loop in a linked list
Use two pointers, one moving one node at a time and the other moving two nodes at a time
If there is a loop, the two pointers will eventually meet
If any of the pointers reach the end of the list, there is no loop
Q38. Explain Merge sort
Merge sort is a divide-and-conquer algorithm that recursively divides an array into two halves, sorts them, and then merges them.
Divide the array into two halves
Recursively sort each half
Merge the sorted halves back together
Repeat until the entire array is sorted
Q39. write code for dfs
DFS (Depth-First Search) is a graph traversal algorithm that explores as far as possible along each branch before backtracking.
DFS uses a stack to keep track of visited nodes and explore adjacent nodes.
It can be implemented recursively or iteratively.
DFS is useful for solving problems like finding connected components, detecting cycles, and solving mazes.
Q40. Rotten oranges problem - DS
Rotten oranges problem involves finding the minimum time required to rot all oranges in a grid.
Use Breadth First Search (BFS) to traverse the grid and update the ripening time of neighboring oranges.
Keep track of the fresh oranges and the time taken to rot them all.
Handle edge cases like no fresh oranges or unreachable oranges.
Q41. system design for parking lot
Design a system for managing a parking lot efficiently.
Use a database to store information about available parking spots, vehicles, and payments.
Implement a system for tracking entry and exit of vehicles.
Include features like online booking, payment options, and real-time availability updates.
Consider implementing a ticketing system for managing parking duration and fees.
Top HR Questions asked in Mehta Jaising Developers
Interview Process at Mehta Jaising Developers
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month