Arcesium
30+ Sakthi Motors Interview Questions and Answers
Q1. Find first missing positive integer from an array for non-negative integers.
Find first missing positive integer from an array of non-negative integers.
Create a hash set to store all positive integers in the array
Loop through the array and add all positive integers to the hash set
Loop through positive integers starting from 1 and return the first missing integer not in the hash set
Q2. Given list of strings group them into distinct anagrams.
Group list of strings into distinct anagrams.
Create a hash table with sorted string as key and list of anagrams as value.
Iterate through the list of strings and add each string to its corresponding anagram list in the hash table.
Return the values of the hash table as a list of lists.
Q3. Find least common ancestor of a binary tree.
Find the lowest common ancestor of a binary tree.
Traverse the tree recursively from the root node.
If the current node is null or matches either of the given nodes, return the current node.
Recursively search for the nodes in the left and right subtrees.
If both nodes are found in different subtrees, return the current node.
If both nodes are found in the same subtree, continue the search in that subtree.
Q4. Connecting Ropes with Minimum Cost
You are given 'N' ropes, each of varying lengths. The task is to connect all ropes into one single rope. The cost of connecting two ropes is the sum of their lengths. Your obj...read more
Given 'N' ropes of varying lengths, find the minimum cost to connect all ropes into one single rope.
Sort the lengths of ropes in ascending order.
Keep connecting the two shortest ropes at each step.
Update the total cost by adding the lengths of the connected ropes.
Repeat until all ropes are connected.
Return the total cost as the minimum cost to connect all ropes.
Q5. Ninja and Binary String Problem Statement
Ninja has a binary string S
of size N
given by his friend. The task is to determine if it's possible to sort the binary string S
in decreasing order by removing any num...read more
Determine if a binary string can be sorted in decreasing order by removing non-adjacent characters.
Check if the count of '1's in the string is equal to the length of the string, in which case it can be sorted in decreasing order.
If there are multiple '0's between two '1's, they can be removed to sort the string in decreasing order.
If there are more '0's than '1's, it is not possible to sort the string in decreasing order.
Q6. Maximum Meetings Problem Statement
Given the schedule of N meetings with their start time Start[i]
and end time End[i]
, you need to determine which meetings can be organized in a single meeting room such that t...read more
Given N meetings with start and end times, determine the maximum number of meetings that can be organized in a single room without overlap.
Sort the meetings based on their end times.
Iterate through the sorted meetings and select the first meeting that does not overlap with the previous one.
Repeat the process until all meetings are considered.
Return the selected meetings in the order they are organized.
Q7. Topological Sort Problem Statement
Given a Directed Acyclic Graph (DAG) consisting of V
vertices and E
edges, your task is to find any topological sorting of this DAG. You need to return an array of size V
repr...read more
Implement a function to find any topological sorting of a Directed Acyclic Graph (DAG).
Use Depth First Search (DFS) to traverse the graph and add vertices to the result in reverse order of finishing times.
Maintain a visited array to keep track of visited vertices to avoid revisiting them.
Start DFS from any unvisited vertex and recursively explore its neighbors.
Once all neighbors are visited, add the current vertex to the result.
Repeat the process until all vertices are visite...read more
Q8. BST to Greater Tree Problem Statement
Given a binary search tree (BST) with 'N' nodes, the task is to convert it into a Greater Tree.
A Greater Tree is defined such that every node's value in the original BST i...read more
Convert a binary search tree into a Greater Tree by replacing each node's value with the sum of all values greater than or equal to it.
Traverse the BST in reverse inorder (right, root, left) to visit nodes in descending order.
Keep track of the running sum of visited nodes and update each node's value with this sum.
Recursively apply the above steps to all nodes in the BST.
Example: Input - 4 1 6 0 2 5 7 -1 -1 -1 3 -1 -1 -1 -1, Output - 20 24 21 15 26 16 7 -1 -1 -1 3 -1 -1 -1 -1
Q9. Optimize Memory Usage Problem Statement
Alex wants to maximize the use of 'K' memory spaces on his computer. He has 'N' different document downloads, each with unique memory usage, and 'M' computer games, each ...read more
Maximize memory usage by pairing downloads and games within memory limit 'K'.
Sort downloads and games in descending order.
Iterate through downloads and games to find the pair with maximum memory usage.
Return the indices of the selected download and game pairs.
Q10. Spiral Order Traversal of a Binary Tree
Given a binary tree with N
nodes, your task is to output the Spiral Order traversal of the binary tree.
Input:
The input consists of a single line containing elements of ...read more
Implement a function to output the Spiral Order traversal of a binary tree given in level order.
Traverse the binary tree in a spiral order, alternating between left to right and right to left at each level.
Use a queue to keep track of nodes at each level and a stack to reverse the order of nodes at odd levels.
Handle null nodes appropriately to maintain the spiral order traversal.
Example: Input: 1 2 3 -1 -1 4 5, Output: 1 3 2 4 5
Q11. N-th Node From The End Problem Statement
You are provided with a Singly Linked List containing integers. Your task is to determine the N-th node from the end of the list.
Example:
Input:
If the list is (1 -> -2...read more
Find the N-th node from the end of a Singly Linked List containing integers.
Traverse the list to find the length L of the list.
Calculate the position of the N-th node from the beginning as L - N + 1.
Traverse the list again to reach the calculated position and return the node's value.
Handle edge cases like N being equal to 1 or equal to the length of the list.
Q12. Bottom View of Binary Tree
Given a binary tree, determine and return its bottom view when viewed from left to right. Assume that each child of a node is positioned at a 45-degree angle from its parent.
Nodes in...read more
Given a binary tree, return the bottom view of the tree when viewed from left to right.
Traverse the tree level by level and keep track of the horizontal distance of each node from the root.
For each horizontal distance, store the node with the maximum depth in a map.
After traversing the entire tree, return the values of the map in sorted order of their horizontal distance.
Q13. Serialize and Deserialize Binary Tree Problem Statement
Given a binary tree of integers, your task is to implement serialization and deserialization methods. You can choose any algorithm for serialization and d...read more
Implement serialization and deserialization methods for a binary tree of integers.
Use level order traversal for serialization and deserialization.
Use -1 to represent null nodes in the binary tree.
Ensure the serialized string can be correctly decoded back to form the original binary tree.
Q14. Number of Islands Problem Statement
You are given a non-empty grid that consists of only 0s and 1s. Your task is to determine the number of islands in this grid.
An island is defined as a group of 1s (represent...read more
The task is to determine the number of islands in a grid consisting of 0s and 1s.
Iterate through the grid and perform depth-first search (DFS) to find connected 1s.
Mark visited 1s as 0 to avoid counting them again.
Increment the island count each time a new island is found.
Consider all 8 adjacent cells (horizontally, vertically, diagonally) while performing DFS.
Handle edge cases like out of bounds and already visited cells.
Q15. Determine the Left View of a Binary Tree
You are given a binary tree of integers. Your task is to determine the left view of the binary tree. The left view consists of nodes that are visible when the tree is vi...read more
The task is to determine the left view of a binary tree, which consists of nodes visible when viewed from the left side.
Traverse the binary tree in a level order manner and keep track of the leftmost node at each level.
Use a queue to perform level order traversal of the binary tree.
Maintain a count of nodes at each level to identify the leftmost node.
Return the leftmost nodes at each level as the left view of the binary tree.
Q16. Design a parking lot
Design a parking lot
Consider the size and capacity of the parking lot
Decide on the layout and organization of parking spaces
Implement a system to manage parking availability and reservations
Include features like ticketing, payment, and security
Consider scalability and future expansion
Q17. Minimum weight to reach bottom right corner in matrix starting from top left. You can move only down and right.
Minimum weight to reach bottom right corner in matrix starting from top left. You can move only down and right.
Use dynamic programming to solve the problem efficiently
Create a 2D array to store the minimum weight to reach each cell
The minimum weight to reach a cell is the minimum of the weight to reach the cell above and the cell to the left plus the weight of the current cell
The minimum weight to reach the bottom right corner is the value in the last cell of the 2D array
Q18. Stock Split, What happens to value of options after stock split?
After a stock split, the value of options will be adjusted based on the new stock price and the split ratio.
Value of options will be adjusted based on the new stock price and the split ratio
Number of options will increase proportionally to the split ratio
Strike price of options will decrease proportionally to the split ratio
Q19. Find nearest index of character in string for each index.
Find the nearest index of a character in a string for each index.
Create an array of strings to store the results.
Loop through each character in the string.
For each character, loop through the rest of the string to find the nearest index of the same character.
Store the result in the array.
Q20. What is Beta, Required Return, Methods of calculating required return?
Beta is a measure of a stock's volatility, required return is the minimum return an investor expects, methods include CAPM and DDM.
Beta measures a stock's volatility in relation to the market.
Required return is the minimum return an investor expects to compensate for the risk of an investment.
Methods of calculating required return include Capital Asset Pricing Model (CAPM) and Dividend Discount Model (DDM).
CAPM formula: Required Return = Risk-Free Rate + Beta * (Market Return...read more
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
Q22. What are futures and forward contracts?
Futures and forward contracts are financial agreements to buy or sell an asset at a specified price on a future date.
Futures contracts are standardized and traded on exchanges, while forward contracts are customized and traded over-the-counter.
Both contracts involve an agreement to buy or sell an asset at a predetermined price on a future date.
Futures contracts require daily settlement of gains and losses, while forward contracts settle at the end of the contract period.
Examp...read more
Q23. 1) Maximum meetings in one room 2)Bottom view of tree 3) Serialize deserialize binary tree 4) Difference between Virtual destructor in java and c++
Interview questions for Software Developer Intern
Maximum meetings in one room can be calculated using greedy approach
Bottom view of tree can be obtained using level order traversal and a map to store horizontal distance
Serialization and deserialization of binary tree can be done using preorder traversal
Virtual destructor in Java is automatically called while in C++ it needs to be explicitly defined
Q24. Missing number in array in 1 to n
Find the missing number in an array of integers from 1 to n.
Create a hash set to store the numbers in the array
Loop through the numbers from 1 to n and check if they are in the hash set
Return the number that is not in the hash set
Q25. Topological Sort along with dry run
Topological Sort is a linear ordering of vertices in a directed acyclic graph.
It is used to find a linear ordering of elements that have dependencies.
It is based on the concept of DFS (Depth First Search).
It can be implemented using both DFS and BFS (Breadth First Search).
It is commonly used in scheduling jobs, resolving dependencies, and compiling code.
Example: Topological sorting of courses to take in a college based on prerequisites.
Q26. Find nth node from last in a linked list in one traversal
To find nth node from last in a linked list in one traversal
Use two pointers, one at the head and the other at nth node from head
Move both pointers simultaneously until the second pointer reaches the end
The first pointer will be at the nth node from last
Q27. Design a 2 player chess game
A 2 player chess game with standard rules and GUI
Implement standard chess rules and moves
Create a GUI for players to interact with the game
Allow players to make moves and track game progress
Incorporate checkmate and stalemate conditions
Implement a timer for each player's turn
Q28. Exposure to financial domain
I have extensive exposure to the financial domain.
I have worked as a Product Manager for a financial services company for 3 years.
I have experience in developing and launching financial products such as credit cards, loans, and savings accounts.
I have a good understanding of financial regulations and compliance requirements.
I have collaborated with cross-functional teams including finance, legal, and compliance to ensure product success.
I have also conducted market research a...read more
Q29. Left view of a tree
The left view of a tree shows the nodes visible from the left side of the tree.
The leftmost node of each level is visible in the left view.
Nodes to the right of the leftmost node are not visible in the left view.
The left view can be obtained using a depth-first search or a breadth-first search algorithm.
Q30. left view of binary tree
Left view of a binary tree is the set of nodes visible when the tree is viewed from the left side.
Traverse the tree level by level from left to right
At each level, add the first node encountered to the result array
Continue this process until all levels are traversed
Interview Process at Sakthi Motors
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month