Optum Global Solutions
Titan Company Interview Questions and Answers
Q1. Shortest Path in Ninjaland
Ninjaland consists of ‘N’ states and ‘M’ paths. Each path connecting two states can either be a normal path or a special path, each with its unique length. Your task is to find the sh...read more
Find the shortest distance between two states in Ninjaland with at most one special path.
Use Dijkstra's algorithm to find the shortest path between two states.
Keep track of the shortest path with at most one special path included.
Consider both normal and special paths while calculating the shortest distance.
Handle cases where multiple paths exist between two states.
Q2. Minimum Direction Changes Problem Statement
Given a 2D grid with 'N' rows and 'M' columns, where each cell contains a character from the set { 'U', 'L', 'D', 'R' } indicating the allowed direction to move to a ...read more
The problem involves finding the minimum number of direction changes needed to create a valid path from the top-left to the bottom-right corner of a 2D grid.
Create a graph representation of the grid with directions as edges.
Use a shortest path algorithm like Dijkstra or BFS to find the minimum number of changes needed.
Handle edge cases like unreachable bottom-right corner or invalid input.
Consider implementing a helper function to convert directions to movements for easier tr...read more
Q3. N Queens Problem
Given an integer N
, find all possible placements of N
queens on an N x N
chessboard such that no two queens threaten each other.
Explanation:
A queen can attack another queen if they are in the...read more
The N Queens Problem involves finding all possible placements of N queens on an N x N chessboard where no two queens threaten each other.
Understand the constraints of the problem: N queens on an N x N chessboard, no two queens can threaten each other.
Implement a backtracking algorithm to explore all possible configurations.
Check for conflicts in rows, columns, and diagonals before placing a queen.
Generate and print valid configurations where queens do not attack each other.
Co...read more
Q4. String Transformation Problem
Given a string (STR
) of length N
, you are tasked to create a new string through the following method:
Select the smallest character from the first K
characters of STR
, remove it fr...read more
Given a string and an integer, create a new string by selecting the smallest character from the first K characters of the input string and repeating the process until the input string is empty.
Iterate through the input string, selecting the smallest character from the first K characters each time.
Remove the selected character from the input string and append it to the new string.
Continue this process until the input string is empty.
Return the final new string formed after the...read more
Q5. 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
Given an array of integers and a target, find all pairs of elements that add up to the target.
Iterate through the array and for each element, check if the target minus the element exists in a hash set.
If it exists, print the pair (element, target-element), otherwise add the element to the hash set.
If no pair is found, print (-1, -1).
Q6. How will you approach a problem which you are completely unaware of
I would start by breaking down the problem, researching similar problems, seeking help from colleagues, and experimenting with different solutions.
Break down the problem into smaller components to understand it better
Research similar problems online or in relevant literature
Seek help from colleagues or mentors who may have experience with similar problems
Experiment with different solutions to see what works best
Q7. FInd the maximium capacity that a thief can thief can stole having W Knapsack capacity
Find maximum capacity a thief can steal with W Knapsack capacity.
Use dynamic programming approach.
Sort items by their value-to-weight ratio.
Iterate through items and update maximum value that can be stolen.
Q8. Middle of the Linked list
Finding the middle node of a linked list.
Traverse the linked list with two pointers, one moving twice as fast as the other.
When the fast pointer reaches the end, the slow pointer will be at the middle node.
If the linked list has even number of nodes, there will be two middle nodes.
In that case, choose either of the middle nodes as the result.
Q9. Reverse words in a sentence
Reverse words in a sentence
Split the sentence into words
Reverse the order of the words
Join the words back into a sentence
Interview Process at Titan Company
Top Associate Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month