10+ PER-SFT Interview Questions and Answers
Q1. Determine Count of Good Triplets
You are given two arrays ARR1
and ARR2
, containing N
and M
elements respectively. There are two types of 'good triplets' that need to be identified in these arrays.
Type 1: A tr...read more
Calculate the total number of 'good triplets' in two arrays based on given conditions.
Iterate through all possible triplets in both arrays and check if they satisfy the conditions
Use nested loops to iterate through all combinations of indices in both arrays
Check the conditions for Type 1 and Type 2 'good triplets' separately
Increment a counter for each valid 'good triplet' found
Return the total count of 'good triplets' for each test case
Q2. Split the String Problem Statement
You are given a string str
consisting of N
lowercase alphabets. Your task is to determine if it is possible to divide the string into three non-empty substrings such that one ...read more
Given a string, determine if it can be split into three non-empty substrings where one is a substring of the other two.
Check if any substring of the string is a substring of the other two substrings.
Iterate through all possible divisions of the string into three non-empty substrings.
Use two pointers to find all possible substrings efficiently.
Q3. Check if Two Trees are Mirror
Given two arbitrary binary trees, your task is to determine whether these two trees are mirrors of each other.
Explanation:
Two trees are considered mirror of each other if:
- The r...read more
Check if two binary trees are mirrors of each other based on specific criteria.
Compare the roots of both trees.
Check if the left subtree of the first tree is the mirror of the right subtree of the second tree.
Verify if the right subtree of the first tree is the mirror of the left subtree of the second tree.
Q4. 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
DFS traversal to find connected components in an undirected and disconnected graph.
Use Depth First Search (DFS) to traverse the graph and find connected components
Maintain a visited array to keep track of visited vertices
For each unvisited vertex, perform DFS to explore the connected component it belongs to
Print the vertices of each connected component in ascending order
Q5. Median of Two Sorted Arrays Problem Statement
Given two sorted integer arrays A
and B
with sizes N
and M
respectively, find the median of the combined array that results from merging arrays A
and B
. If the tota...read more
Find the median of two sorted arrays after merging them.
Merge the two sorted arrays into one sorted array.
Calculate the median based on the length of the combined array.
Handle cases where the total number of elements is even or odd.
Q6. Snake and Ladder Problem Statement
Given a 'Snake and Ladder' board with N rows and N columns, where positions are numbered from 1 to (N*N) starting from the bottom left, alternating direction each row, find th...read more
Find the minimum number of dice throws required to reach the last cell on a 'Snake and Ladder' board.
Use Breadth First Search (BFS) to find the shortest path from the starting cell to the last cell.
Maintain a queue to explore all possible moves from each cell.
Consider the effect of snakes and ladders on the movement of the player.
Handle the case where the last cell is unreachable by returning -1.
Optimize the solution by using a visited array to avoid revisiting cells.
Q7. Longest Palindromic Subsequence Problem Statement
Given a string A
consisting of lowercase English letters, determine the length of the longest palindromic subsequence within A
.
Explanation:
- A subsequence is d...read more
Find the length of the longest palindromic subsequence in a given string of lowercase English letters.
Use dynamic programming to solve this problem efficiently.
Create a 2D array to store the lengths of palindromic subsequences for different substrings.
Fill the array diagonally based on the characters in the string.
Return the length of the longest palindromic subsequence for each test case.
Q8. Stack with getMin Operation
Create a stack data structure that supports not only the usual push and pop operations but also getMin(), which retrieves the minimum element, all in O(1) time complexity without usi...read more
Implement a stack with push, pop, top, isEmpty, and getMin operations in O(1) time complexity without using extra space for storing additional stack data structures.
Use two stacks - one to store the actual elements and another to store the minimum element at each level of the main stack.
When pushing an element, compare it with the current minimum and update the minimum stack accordingly.
For getMin operation, simply return the top element of the minimum stack.
Ensure all operat...read more
Q9. Binary Tree to Doubly Linked List
Transform a given Binary Tree into a Doubly Linked List.
Ensure that the nodes in the Doubly Linked List follow the Inorder Traversal of the Binary Tree.
Input:
The first line ...read more
Convert a Binary Tree into a Doubly Linked List following Inorder Traversal.
Perform Inorder Traversal of the Binary Tree to get the nodes in order.
Create a Doubly Linked List by linking the nodes in the order obtained from Inorder Traversal.
Return the head of the Doubly Linked List as the output.
Q10. 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 any algorithm for serialization and deserialization.
Ensure the serialized string can be correctly decoded back to form the original binary tree.
Nodes are separated by spaces, and -1 is used to depict a null node.
Output the level order traversal of the deserialized binary tree with nodes separated by single spaces.
Q11. Shuffle Two Strings
You are provided with three strings: A
, B
, and C
. Your task is to determine if C
is formed by interleaving A
and B
. A string C
is considered an interleaving of A
and B
if:
- The length of
C
i...read more
Determine if a string C is formed by interleaving two strings A and B.
Check if the length of C is equal to the sum of lengths of A and B.
Ensure all characters of A and B are present in C.
Verify that the order of characters in C matches the order in A and B.
Q12. You are given a large array of n bits. Each bit is initially 0. You perform several operations of the type
Solution to performing operations on a large array of bits.
Use bitwise operators to perform operations on individual bits
Use a loop to iterate through the array and perform the operations
Ensure that the array is large enough to accommodate all the bits
Consider using a data structure like a bitset for efficient bit manipulation
Q13. Palindrome Permutation - Problem Statement
Determine if a permutation of a given string S
can form a palindrome.
Example:
Input:
string S = "aab"
Output:
"True"
Explanation:
The permutation "aba" of the string ...read more
Check if a permutation of a string can form a palindrome.
Create a frequency map of characters in the string.
Count the number of characters with odd frequencies.
If there is at most one character with an odd frequency, return true.
Otherwise, return false.
Q14. Tell me about mud logging work? What is viscosity and density and porosity and permiablity? And related questions in drilling and geology
Mud logging involves monitoring drilling parameters to analyze rock formations. Viscosity, density, porosity, and permeability are key properties in drilling and geology.
Mud logging involves analyzing drilling cuttings and fluids to determine rock properties and detect hydrocarbons.
Viscosity refers to a fluid's resistance to flow, important for maintaining drilling mud circulation.
Density is the mass per unit volume of a substance, crucial for balancing well pressure.
Porosity...read more
Using a map-based design to check for isomorphic words in a file.
Create a map where the key is the sorted characters of a word and the value is a list of words with the same sorted characters.
Iterate through the file, for each word, sort its characters and check if it exists in the map. If it does, add the word to the list. If not, create a new entry in the map.
After processing the file, iterate through the map and output the lists of isomorphic words.
Q16. Sort a stack using a stack
Sort a stack using another stack
Create an empty temporary stack
Pop elements from the original stack and push them onto the temporary stack in sorted order
Pop elements from the temporary stack back to the original stack
Top HR Questions asked in PER-SFT
Interview Process at PER-SFT
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month