Expedia Group
20+ McDermott International Interview Questions and Answers
Q1. Problem Statement: Largest Subarray with Equal Number of 0s and 1s
Given an array containing only 0s and 1s, determine the length of the longest contiguous subarray that has an equal number of 0s and 1s.
Input:...read more
Q2. Maximum Sum of Two Non-Overlapping Subarrays
Given an integer array ARR
and a positive integer K
, your objective is to find two non-overlapping subarrays (contiguous) of length K
each, such that their summed to...read more
Q3. Gas Tank Problem Statement
You have a car with a gas tank of infinite capacity. There are 'N' gas stations located along a circular route, numbered from 0 to N-1. You begin your journey with an empty tank from ...read more
Q4. Knight Probability in Chessboard
Calculate the probability that a knight remains on an N x N chessboard after making K moves. Initially, the knight is placed at a given position on the board. It can move in any...read more
Calculate the probability that a knight remains on an N x N chessboard after making K moves.
Use dynamic programming to calculate the probability of the knight staying on the board after each move.
Consider all possible moves the knight can make from its current position.
Keep track of the probabilities at each position on the board after each move.
Normalize the probabilities at the end to get the final result.
Example: For a 3x3 board and 2 moves, the probability of the knight s...read more
Q5. Anagram Difference Problem Statement
Given two strings, 'STR1' and 'STR2', of equal lengths, determine the minimum number of manipulations required to make the two strings anagrams of each other.
Input:
The fir...read more
Q6. Count Nodes within K-Distance Problem Statement
Given a connected, undirected, and acyclic graph where some nodes are marked and a positive integer 'K'. Your task is to return the count of nodes such that the d...read more
Q7. String Rearrangement Problem Statement
You are given a string of lowercase characters. The objective is to rearrange (reorder) the string so that no two adjacent characters are identical.
Return the rearranged ...read more
The objective is to rearrange a string so that no two adjacent characters are identical. Return the rearranged string or 'NO SOLUTION'.
Iterate through the string and count the frequency of each character.
Create two lists, one for characters with odd frequency and one for characters with even frequency.
If the count of characters with odd frequency is greater than 1, return 'NO SOLUTION'.
Alternate between characters with even and odd frequency to create the rearranged string.
Q8. Boundary Traversal of Binary Tree
Given a binary tree of integers, your task is to print the boundary nodes of this binary tree in an anti-clockwise direction starting from the root node.
Input:
The first line ...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 connecting the nodes in the order obtained from Inorder Traversal.
Return the head of the Doubly Linked List as the output.
Q10. Remove Character from String Problem Statement
Given a string str
and a character 'X', develop a function to eliminate all instances of 'X' from str
and return the resulting string.
Input:
The first line contai...read more
Develop a function to remove all instances of a given character from a string.
Iterate through the string character by character and skip the character to be removed.
Build a new string by appending characters that are not equal to the given character.
Return the final modified string.
Handle edge cases like empty string or character not found in the string.
Q11. 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
Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraints.
Use a combination of a doubly linked list and a hashmap to efficiently implement the LRU cache.
Keep track of the least recently used item and update it accordingly when new items are added.
Ensure that the cache does not exceed its capacity by evicting the least recently used item when necessary.
Q12. Problem: Deletion in Circular Linked List
You are provided with a Circular Linked List of integers and a specific integer, referred to as 'key'
.
Your task is to implement a function that locates the specified k...read more
Implement a function to delete a specific key from a Circular Linked List of integers.
Traverse the Circular Linked List to find the key to be deleted.
Adjust the pointers to remove the node containing the key.
Handle the case where the Circular Linked List becomes empty after deletion.
Return -1 if the Circular Linked List is empty after deletion.
Q13. Page Faults Identification Problem Statement
In computing, a page fault occurs when a process accesses a memory page that is not currently mapped by the memory management unit. To handle new pages being brought...read more
The problem involves determining the number of page faults using the Least Recently Used (LRU) replacement algorithm.
Page faults occur when a process accesses a memory page not currently mapped by the memory management unit.
Page replacement algorithm like LRU is used to decide which existing page should be replaced.
The goal is to calculate the number of page faults based on the given input sequences and memory capacity.
Constraints include the number of test cases, number of p...read more
Q14. Closest Sum Problem Statement
Given an array of integers ARR
of size N
and an integer target
, find three integers in ARR
such that their sum is closest to the target
. If there are two closest sums, return the s...read more
Find three integers in an array whose sum is closest to a given target, return the smallest sum if there are two closest sums.
Iterate through all possible triplets in the array to find the sum closest to the target.
Keep track of the closest sum found so far and update it if a closer sum is found.
Return the closest sum at the end of the iteration.
Q15. Deletion in Circular Linked List Problem Statement
Given a Circular Singly Linked List of integers, and a specific value 'VAL', your task is to delete the first occurrence of this value in the linked list. If t...read more
Delete the first occurrence of a specific value in a Circular Linked List.
Traverse the circular linked list to find the value to be deleted.
Update the pointers to skip the node containing the value.
Handle edge cases like deleting the only node in the list.
Return the modified circular linked list.
Q16. 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
Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.
Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.
If the two pointers meet at any point, it indicates the presence of a cycle in the linked list.
Use Floyd's Cycle Detection Algorithm for efficient detection of cycles in a linked list.
Q17. Find Duplicates in an Array
Given an array ARR
of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.
Return the duplicate elements in any order. If n...read more
Find duplicates in an array of integers within a specified range.
Iterate through the array and keep track of the count of each element using a hashmap.
Return elements with count greater than 1 as duplicates.
Time complexity can be optimized to O(N) using a set to store duplicates.
Interview Process at McDermott International
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month