60+ Test Yantra Software Solutions Interview Questions and Answers
Q1. Saving Money Problem Statement
Ninja is adventurous and loves traveling while being mindful of his expenses. Given a set of 'N' stations connected by 'M' trains, each train starting from station 'A' and reachin...read more
The task is to find the cheapest price from the given source to destination with up to K stops.
Read the number of test cases
For each test case, read the number of stations and trains
Read the details of each train (source, destination, ticket price)
Read the source station, destination station, and maximum number of stops
Implement a graph data structure to represent the stations and trains
Use a modified version of Dijkstra's algorithm to find the cheapest price with up to K sto...read more
Q2. Longest Increasing Path in a 2D Matrix Problem Statement
Given a matrix of non-negative integers of size 'N x M', where 'N' and 'M' denote the number of rows and columns respectively, find the length of the lon...read more
The task is to find the length of the longest increasing path in a 2D matrix, where you can move in four directions: left, right, up, or down from each cell.
Traverse the matrix and for each cell, find the longest increasing path starting from that cell
Use dynamic programming to store the length of the longest increasing path for each cell
Recursively explore all four directions from each cell, checking if the next cell is greater than the current cell
Keep track of the maximum ...read more
Q3. Base 58 Conversion Problem Statement
You are given a decimal number 'N'. Your task is to convert this number into a base 58 representation.
The Base58 alphabet is defined by the following characters: “123456789...read more
Q4. Binary Tree Construction from Preorder and Inorder Traversal
The goal is to construct a binary tree from given preorder and inorder traversal lists of the tree nodes.
Example:
Input:
preorder = [1, 2, 4, 7, 3]
i...read more
The task is to construct a binary tree using the given inorder and preorder traversals.
Use the preorder traversal to determine the root of the binary tree
Use the inorder traversal to determine the left and right subtrees of the root
Recursively construct the left and right subtrees
Return the root node of the constructed binary tree
Q5. Given a hashmap M which is a mapping of characters to arrays of substitute characters, and an input string S, return an array of all possible mutations of S (where any character in S can be substituted with one...
read moreGiven a hashmap M and an input string S, return an array of all possible mutations of S using M's substitutes.
Iterate through each character in S and get its substitutes from M
Use recursion to generate all possible combinations of substitutes for each character
Time complexity: O(n^m) where n is the average number of substitutes per character and m is the length of S
Space complexity: O(n^m) due to the number of possible combinations
Optimization: Use memoization to store previo...read more
Q6. Bird and Maximum Fruit-Gathering Problem Statement
A ninja bird can gather fruits from trees arranged in a circle. Each tree has an associated fruit value. The bird can gather all the fruits from a tree in 0.5 ...read more
Q7. Combination Sum Problem Statement
Given an array of distinct positive integers ARR
and a non-negative integer 'B', find all unique combinations in the array where the sum is equal to 'B'. Numbers can be chosen ...read more
The task is to find all unique combinations in an array whose sum is equal to a given target sum.
Use backtracking to generate all possible combinations
Sort the array in non-decreasing order to ensure elements in each combination are in non-decreasing order
Start with an empty combination and iterate through the array, adding each element to the combination and recursively calling the function with the remaining sum
If the sum becomes zero, add the combination to the result
If th...read more
Q8. Given an “id” and a function getFriends(id) to get the list of friends of that person id, write a function that returns the list of “friends of friends” in the order of decreasing number of mutual friends, as i...
read moreFunction to return list of friends of friends in decreasing order of mutual friends
Use a set to store all friends of friends
Iterate through the list of friends of the given id
For each friend, iterate through their list of friends and count mutual friends
Sort the set of friends of friends by decreasing number of mutual friends
Q9. Given a list of integer numbers, a list of symbols [+,-,*,/] and a target number N, provide an expression which evaluates to N or return False if that is not possible. e.g. let the list of numbers be [1,5,5] an...
read moreGiven a list of numbers and symbols, provide an expression that evaluates to a target number.
Use recursion to try all possible combinations of numbers and symbols
Check for division by zero and negative numbers
Return False if no expression evaluates to the target number
Q10. K Closest Points to Origin Problem Statement
Your house is located at the origin (0,0) of a 2-D plane. There are N
neighbors living at different points on the plane. Your goal is to visit exactly K
neighbors wh...read more
Q11. Longest Increasing Subsequence Problem Statement
Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more
Q12. Interleaving Two Strings Problem Statement
You are given three strings 'A', 'B', and 'C'. Determine if 'C' is formed by interleaving 'A' and 'B'.
String 'C' is an interleaving of 'A' and 'B' if the length of 'C...read more
Q13. Path Counting in Directed Graph
Given a directed graph with a specified number of vertices V
and edges E
, your task is to calculate the total number of distinct paths from a given source node S
to all other no...read more
Q14. Merging Accounts Problem
Given a list ACCOUNTS
where each element consists of a list of strings, with the first element being the name of the account holder, and the subsequent elements being the email addresse...read more
The task is to merge accounts belonging to the same person based on common emails and return the merged accounts.
Iterate through each account and create a mapping of emails to account holders
Iterate through the mapping and merge accounts with common emails
Sort the merged accounts and return the result
Q15. Search In Rotated Sorted Array Problem Statement
Given a rotated sorted array ARR
of size 'N' and an integer 'K', determine the index at which 'K' is present in the array.
Note:
1. If 'K' is not present in ARR,...read more
Q16. All Prime Numbers Less Than or Equal to N
Given a positive integer N
, your task is to return all the prime numbers less than or equal to N
.
Note:
1) A prime number is a number that has only two factors: 1 and t...read more
Q17. K - Sum Path In A Binary Tree
Given a binary tree where each node contains an integer value, and a value 'K', your task is to find all the paths in the binary tree such that the sum of the node values in each p...read more
The task is to print every path of a binary tree with the sum of nodes in the path as 'K'.
Traverse the binary tree and keep track of the current path and its sum
At each node, check if the sum of the current path equals 'K'
If yes, add the current path to the result
Continue traversing the left and right subtrees recursively
Remove the current node from the path before backtracking
Q18. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
Q19. 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
Q20. Arithmetic Expression Evaluation Problem Statement
You are provided with a string expression
consisting of characters '+', '-', '*', '/', '(', ')' and digits '0' to '9', representing an arithmetic expression in...read more
Q21. Roman Numeral to Integer Conversion
Convert a string representing a Roman numeral into its integer equivalent and return the result.
Explanation:
Roman numerals are represented by seven different symbols: I, V,...read more
Q22. Course Schedule II Problem Statement
You are provided with a number of courses 'N', some of which have prerequisites. There is a matrix named 'PREREQUISITES' of size 'M' x 2. This matrix indicates that for ever...read more
Q23. 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
Q24. 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
Q25. 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
Q26. Power Set Generation
Given a sorted array of 'N' integers, your task is to generate the power set for this array. Each subset of this power set should be individually sorted.
A power set of a set 'ARR' is the s...read more
Q27. Rank from Stream Problem Statement
Given an array of integers ARR
and an integer K
, determine the rank of the element ARR[K]
.
Explanation:
The rank of any element in ARR
is defined as the number of elements sma...read more
Q28. Longest Route Problem Statement
Given a 2-dimensional binary matrix called Mat
of size N x M that consists solely of 0s and 1s, find the length of the longest path from a specified source cell to a destination ...read more
Q29. Get DFS Path Problem Statement
Given an undirected graph represented by vertices and edges, identify and return a path between two specified vertices using Depth First Search (DFS). The path should be presented...read more
Q30. Running Absolute Difference in Arrays
Given an array ARR
consisting of 'N' non-negative integers, compute the running absolute difference of elements at even and odd index positions, respectively.
Input:
An int...read more
Q31. Given two “ids” and a function getFriends(id) to get the list of friends of that person id, write a function that returns the list of mutual friends
Function to return mutual friends given two ids and getFriends(id) function
Call getFriends(id) for both ids to get their respective friend lists
Iterate through both lists and compare to find mutual friends
Return the list of mutual friends
Q32. Remove Duplicates from Sorted Array Problem Statement
You are given a sorted integer array ARR
of size N
. Your task is to remove the duplicates in such a way that each element appears only once. The output shou...read more
Q33. Given a number of time slots – start time and end time,“a b”, find any specific time with the maximum number of overlapping. After solving the problem I had to prove my solution
Given time slots, find a specific time with maximum overlap. Prove solution.
Create a list of all start and end times
Sort the list in ascending order
Iterate through the list and keep track of the number of overlaps at each time
Return the time with the maximum number of overlaps
Prove solution by testing with different input sizes and edge cases
Q34. You have a number of incoming Integers, all of which cannot be stored into memory. We need to print largest K numbers at the end of input
Use a min-heap to keep track of the largest K numbers seen so far.
Create a min-heap of size K.
For each incoming integer, add it to the heap if it's larger than the smallest element in the heap.
If the heap size exceeds K, remove the smallest element.
At the end, the heap will contain the largest K numbers in the input.
Q35. Given an array of Integers, find the Longest sub-array whose elements are in Increasing Order
Find the longest sub-array with increasing order of integers.
Iterate through the array and keep track of the current sub-array's start and end indices.
Update the start index whenever the current element is smaller than the previous element.
Update the end index whenever the current element is greater than or equal to the next element.
Calculate the length of the sub-array and compare it with the longest sub-array found so far.
Return the longest sub-array.
Q36. How will you describe iOS manual memory management for a new developer in few words?
iOS manual memory management requires developers to manually allocate and deallocate memory for objects.
Developers must manually allocate memory for objects using methods like alloc and init.
Developers must also manually deallocate memory for objects using methods like release.
Failure to properly manage memory can lead to memory leaks and crashes.
ARC (Automatic Reference Counting) was introduced in iOS 5 to automate memory management.
However, manual memory management is still...read more
Q37. Write a program to print the powerset. E.g. given this set {1,2,3}, it will print {},{1},{2},{3},{1,2},{1,3}, {2,3}, {1,2,3}
Program to print powerset of a given set
Create an empty list to store subsets
Loop through all possible binary numbers from 0 to 2^n-1 where n is the length of the set
For each binary number, convert it to binary and use the 1's as indices to select elements from the set
Add the selected elements to the list of subsets
Return the list of subsets
Q38. Given a Sorted Array which has been rotated, write the code to find a given Integer
Code to find a given integer in a rotated sorted array.
Use binary search to find the pivot point where the array is rotated.
Divide the array into two subarrays and perform binary search on the appropriate subarray.
Handle edge cases such as the target integer not being present in the array.
Q39. Given an array of Integers, find the length of Longest Increasing Subsequence and print the sequence.
Find the length of longest increasing subsequence and print the sequence from an array of integers.
Use dynamic programming to solve the problem
Create an array to store the length of longest increasing subsequence ending at each index
Traverse the array and update the length of longest increasing subsequence for each index
Print the sequence by backtracking from the index with the maximum length
Time complexity: O(n^2)
Example: Input array [3, 4, -1, 0, 6, 2, 3], output length 4 a...read more
Q40. Given an expression (in single variable) like 4x+13(x-(4x+x/3)) = 9, evaluate x The expression is a string and the variable is always x
Solve for x in a given expression with single variable.
Simplify the expression by applying the distributive property and combining like terms.
Isolate the variable term on one side of the equation and the constant terms on the other side.
Solve for x by dividing both sides of the equation by the coefficient of the variable term.
Check the solution by substituting the value of x back into the original equation.
In this case, simplify the expression to -5x/3 = -4 and solve for x to...read more
Facebook stores likes/dislikes using a combination of databases and caching systems.
Likes/dislikes are stored in a distributed database system like Cassandra or HBase.
Each like/dislike is associated with a user and the content being liked/disliked.
The database is sharded to handle the large volume of likes/dislikes.
Caching systems like Memcached or Redis are used to improve read performance.
Likes/dislikes can be stored as separate entities or as counters depending on the use ...read more
Facebook implements graph search by indexing user connections and content to enable efficient search queries.
Facebook indexes user connections and content to build a graph database.
The graph database is used to store and retrieve information about users, their relationships, and their content.
Graph search queries are executed by traversing the graph database to find relevant connections and content.
Facebook uses various algorithms and optimizations to improve the efficiency a...read more
Q43. Brain storming:How does facebook implement graph search
Facebook implements graph search by indexing user data and using natural language processing.
Facebook indexes user data to create a graph of connections and relationships.
Natural language processing is used to interpret user queries and return relevant results.
Graph search allows users to search for specific information within their network, such as 'friends who like hiking'.
Q44. Given a set of 2D points, some integer k, find the k points closest to the origin, (0,0)
Find k closest points to origin from a set of 2D points.
Calculate distance of each point from origin using distance formula
Sort the points based on distance in ascending order
Return first k points from the sorted list
Q45. Explain more about hadoop and how it is used ?
Hadoop is a distributed computing framework used for storing and processing large datasets.
Hadoop is based on the MapReduce programming model.
It allows for parallel processing of large datasets across multiple nodes.
Hadoop consists of two main components: HDFS for storage and MapReduce for processing.
It is commonly used for big data analytics, machine learning, and data warehousing.
Examples of companies using Hadoop include Facebook, Yahoo, and eBay.
Facebook Chat is a real-time messaging system that allows users to send and receive instant messages.
Facebook Chat uses a client-server architecture.
It utilizes long polling or WebSockets for real-time communication.
Messages are stored in a message queue for delivery.
Chat messages are encrypted for security.
Facebook Chat supports features like read receipts, typing indicators, and group chats.
Q47. Convert a string of Roman numerals to an integer in O(n) time
Convert Roman numerals to integer in O(n) time
Create a dictionary to map Roman numerals to integers
Iterate through the string from right to left
If the current numeral is less than the previous, subtract it from the total
Else, add it to the total
Return the total
Q49. How do u implement status updates ?
Status updates can be implemented through various methods such as push notifications, real-time updates, and periodic polling.
Use push notifications to instantly update users on important changes.
Implement real-time updates using websockets or server-sent events for a seamless user experience.
Periodically poll the server for updates using AJAX or other similar technologies.
Provide a clear and concise interface for users to view and interact with status updates.
Consider implem...read more
Q50. How does fb store likes/dislikes ?
Facebook stores likes/dislikes as data points in their database.
Likes and dislikes are stored as separate data points.
Each like/dislike is associated with a unique ID for the post or comment.
The data is stored in Facebook's database and can be accessed through their API.
Likes/dislikes can also be used to personalize a user's newsfeed.
Facebook also uses likes/dislikes to gather data for targeted advertising.
Q51. How do fb messages work ?
FB messages work by allowing users to send and receive text, images, videos, and other media through the Facebook platform.
Messages can be sent to individuals or groups of people.
Users can also send voice messages and make voice and video calls through the messaging feature.
Messages can be archived or deleted, and users can also choose to ignore or block certain senders.
Facebook uses end-to-end encryption to protect the privacy and security of messages.
Messages can be accesse...read more
Q52. How does fb mail work ?
FB Mail is a messaging service that allows Facebook users to send and receive messages from other users.
FB Mail is integrated into the Facebook platform and can be accessed through the Messenger app or website.
Users can send messages to individuals or groups, and can also attach files, photos, and videos.
FB Mail also includes features such as message requests, message filtering, and message archiving.
Messages can be sent and received in real-time, and users can also receive n...read more
Q53. What are your favorite products and how would you improve them..?
My favorite product is the iPhone. I would improve it by increasing battery life and adding more customization options.
Increase battery life
Add more customization options
Improve Siri's functionality
Make the camera even better
Offer more color options
Demand paging is a memory management technique where pages are loaded into memory only when needed.
Demand paging allows for efficient memory utilization by loading pages into memory on demand.
It reduces the amount of initial memory required to start a process.
When a page is needed but not in memory, a page fault occurs and the required page is loaded from disk.
Demand paging allows for larger virtual memory space than physical memory.
Examples of demand paging systems include W...read more
Q55. Who is responsible for illegal rules?
The responsibility for illegal rules lies with the individuals or entities that create and enforce them.
Illegal rules are typically created by individuals or organizations in positions of authority or power.
Government bodies, legislative bodies, or regulatory agencies may be responsible for creating illegal rules.
Enforcement agencies, such as the police or regulatory authorities, may be responsible for enforcing illegal rules.
Individuals who knowingly break the law by creatin...read more
Q56. what you have technical improvement in codes?
I have implemented various technical improvements in codes to enhance performance and functionality.
Implemented caching mechanisms to reduce load times
Optimized database queries for faster retrieval of data
Introduced error handling techniques to improve code reliability
Utilized design patterns to make the codebase more maintainable
Refactored legacy code to adhere to best practices
Q57. Implement LRU Cache
LRU Cache is a data structure that stores the most recently used items and discards the least recently used items.
Use a doubly linked list to keep track of the order of items in the cache
Use a hash map to store the key-value pairs for fast access
When an item is accessed, move it to the front of the linked list
When the cache is full, remove the least recently used item from the back of the linked list and the hash map
Q58. What is the best way to keep man alive
The best way to keep a man alive is to ensure he has access to basic necessities like food, water, shelter, and medical care.
Provide access to clean drinking water
Ensure a balanced and nutritious diet
Provide adequate shelter and protection from the elements
Ensure access to medical care and treatment
Encourage regular exercise and physical activity
Q59. how you can be good analyser data
To be a good data analyzer, one needs to have strong analytical skills and attention to detail.
Develop strong analytical skills through practice and training
Pay attention to details and look for patterns in the data
Use tools and software to help with data analysis
Stay up-to-date with industry trends and best practices
Collaborate with others to gain different perspectives on the data
Validate and verify data to ensure accuracy
Communicate findings clearly and effectively
Q60. Do you know what is Spark?
Spark is a distributed computing framework used for big data processing.
Spark is an open-source project under Apache Software Foundation.
It can process data in real-time and batch mode.
Spark provides APIs for programming in Java, Scala, Python, and R.
It can be used for various big data processing tasks like machine learning, graph processing, and SQL queries.
Spark uses in-memory processing for faster data processing.
Q61. Can you set learning goals?
Yes, learning goals are essential for personal and professional growth.
Learning goals help in setting a clear direction for learning and development.
They provide motivation and focus to achieve desired outcomes.
Examples of learning goals include improving communication skills, learning a new language, or mastering a new software tool.
Learning goals should be specific, measurable, achievable, relevant, and time-bound (SMART).
Q62. How an elephant die with ant
It's impossible for an elephant to die from an ant.
Ants are too small to cause any harm to an elephant.
Elephants have thick skin which protects them from insect bites.
Even if an elephant accidentally ingests an ant, it won't cause any harm.
This question is likely a trick or joke question.
Q63. System design of proximity service
Design a system for proximity service
Utilize geolocation data to track user locations
Implement algorithms to calculate proximity between users
Use real-time updates to notify users of nearby contacts
Q64. what is class in java
A class in Java is a blueprint or template for creating objects that define the properties and behaviors of those objects.
A class is a fundamental building block in Java programming.
It encapsulates data and methods that operate on that data.
Objects are instances of classes.
Classes can be inherited to create new classes with additional or modified functionality.
Example: class Car { String color; void start() { ... } }
Q65. Draw architecture design pattern
MVC (Model-View-Controller) architecture design pattern separates an application into three main components.
Model: Represents the data and business logic of the application
View: Represents the UI components of the application
Controller: Acts as an intermediary between Model and View, handling user input and updating the Model accordingly
Q66. Implement key value store
Implement a key value store for storing and retrieving data efficiently.
Use a hash table or a balanced tree data structure to store key-value pairs.
Implement functions for inserting, updating, deleting, and retrieving key-value pairs.
Consider implementing features like transactions, concurrency control, and data persistence.
Example: Implement a simple key value store using a hash table in Python.
Q67. Oops concept in java
Oops concept in Java
Object-oriented programming paradigm
Encapsulation, Inheritance, Polymorphism, Abstraction
Classes, Objects, Methods, and Properties
Code reusability and modularity
Example: Creating a class 'Car' with properties like 'color' and 'speed', and methods like 'start' and 'stop'
Top HR Questions asked in Test Yantra Software Solutions
Interview Process at Test Yantra Software Solutions
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month