Directi Interview Questions  

See also
Arcesium Coding Interview Questions

Array Questions Directi

Question 1. Check if Array Contains Contiguous Integers With Duplicates Allowed You are given an array of integers which can contain duplicate elements as well. The problem statement asks to find out if it is a set of contiguous integers, print “Yes” if it is, print “No” if it is not. Example   Sample Input: [2, 3, 4, 1, 7, 9] Sample ...

Read more

Question 2. Maximum possible difference of two subsets of an array Suppose, we have an integer array. The problem statement “Maximum possible difference of two subsets of an array” asks to find out the maximum possible difference between the two subsets of an array. Conditions to be followed: An array can contain repeating elements, but the highest frequency of an element ...

Read more

Question 3. Minimum operation to make all elements equal in array The problem “Minimum operation to make all elements equal in array” states that you are given an array with some integers in it. You have to find out the minimum operations that can be done to make an array equal. Example   [ 1,3,2,4,1] 3 Explanation Either 3 subtractions can be ...

Read more

Question 4. Generate all possible sorted arrays from alternate elements of two given sorted arrays The problem “Generate all possible sorted arrays from alternate elements of two given sorted arrays” states that suppose you have two sorted arrays. The problem statement asks to find out all the possible sorted arrays, such that number should be arranged alternatively from the two given different arrays. Example   ArrA[] ...

Read more

Question 5. Difference Array | Range update query in O(1) You are given an integer array and two types of queries, one is to add a given number in a range and the other to print the whole array. The problem “Difference Array | Range update query in O(1)” requires us to perform the range updates in O(1). Example   arr[] ...

Read more

Question 6. Constant time range add operation on an array You have given an integer array and initially, it was initialized as 0 and also given a range. The task is to add the given number in the range of the array and print the resultant array. Example   arr[] = {0, 0, 0, 0, 0} Query: {(0, 2, 50), (3, ...

Read more

Question 7. Find all pairs (a, b) in an array such that a % b = k Problem Statement   The problem “Find all pairs (a, b) in an array such that a % b = k” states that you are given an array of integers and an integer value called k. The problem statement asks to find out the pair in such a way that that x ...

Read more

Question 8. Range LCM Queries Problem Statement   The problem “Range LCM Queries” states that you have an integer array and q number of queries. Each query contains the (left, right) as a range. The given task is to find out the LCM(left, right), i.e, LCM of all the number that comes in the range of ...

Read more

Question 9. Queries on XOR of greatest odd divisor of the range Problem Statement   The problem “Queries on XOR of greatest odd divisor of the range” states that you are given an array of integer and query q, each query consists of a range. The problem statement asks to find out the XOR of the greatest odd divisor within the given range ...

Read more

Question 10. Subset with sum divisible by m Problem Statement   The problem “Subset with sum divisible by m” states that you are given an array of non-negative integers and an integer m. Now you need to find if there is a subset having sum divisible by m. That is the sum of the subset should give 0 as ...

Read more

Question 11. Find pairs with given sum such that elements of pair are in different rows Problem Statement   “Find pairs with given sum such that elements of pair are in different rows” problem states that you are given a matrix of integers and a value called “sum”. The problem statement asks to find out all the pairs in a matrix that sums up to a given ...

Read more

Question 12. Maximum Subarray Sum Excluding Certain Elements Problem Statement   We are given an array, and we need to find maximum subarray sum excluding certain elements. That is, we need to find the max sum of subarray such that the subarray we are considering does not contain the elements which are told to be excluded. Example of maximum ...

Read more

Question 13. Printing brackets in Matrix Chain Multiplication Problem Problem Statement   We need to find the order of multiplication of matrices such that the number of operations involved in the multiplication of all the matrices is minimized. Then we need to print this order i.e. printing brackets in matrix chain multiplication problem. Consider you have 3 matrices A, B, ...

Read more

Question 14. Largest rectangular sub-matrix whose sum is 0 Problem Statement   Find the maximum size sub-matrix in a 2D array whose sum is zero. A sub-matrix is nothing but a 2D array inside of the given 2D array. So, you have a matrix of signed integers, you need to calculate the sum of sub-matrices and find the matrix with ...

Read more

Question 15. Find Three Element From Different Three Arrays Such That a + b + c = sum Three Sum is a problem loved by interviewers. It is a problem I was personally asked during the Amazon interview. So, without wasting any more time let us get to the problem. An array that has both positive and negative numbers. Three numbers that sum up to zero/can be modified, ...

Read more

Question 16. Find Maximum of Minimum for Every Window Size in a Given Array Given an array a[ ] of size n. For every window size that varies from 1 to n in array print or find maximum of minimum for every window size in a given array. Example   Input : a[ ] = {10, 20, 30, 50, 10, 70, 30} Output : 70 30 20 ...

Read more

String Questions Directi

Question 17. Minimum insertions to form a palindrome with permutations allowed The problem “Minimum insertions to form a palindrome with permutations allowed” states that you are given a String with all letters in lowercase. The problem statement asks to find out the minimum insertion of a character to a string that it can become Palindrome. The position of characters can be ...

Read more

Question 18. Check if Array Contains Contiguous Integers With Duplicates Allowed You are given an array of integers which can contain duplicate elements as well. The problem statement asks to find out if it is a set of contiguous integers, print “Yes” if it is, print “No” if it is not. Example   Sample Input: [2, 3, 4, 1, 7, 9] Sample ...

Read more

Tree Questions Directi

Question 19. Range LCM Queries Problem Statement   The problem “Range LCM Queries” states that you have an integer array and q number of queries. Each query contains the (left, right) as a range. The given task is to find out the LCM(left, right), i.e, LCM of all the number that comes in the range of ...

Read more

Stack Questions Directi

Question 20. Find Maximum of Minimum for Every Window Size in a Given Array Given an array a[ ] of size n. For every window size that varies from 1 to n in array print or find maximum of minimum for every window size in a given array. Example   Input : a[ ] = {10, 20, 30, 50, 10, 70, 30} Output : 70 30 20 ...

Read more

Matrix Questions Directi

Question 21. Find pairs with given sum such that elements of pair are in different rows Problem Statement   “Find pairs with given sum such that elements of pair are in different rows” problem states that you are given a matrix of integers and a value called “sum”. The problem statement asks to find out all the pairs in a matrix that sums up to a given ...

Read more

Question 22. Printing brackets in Matrix Chain Multiplication Problem Problem Statement   We need to find the order of multiplication of matrices such that the number of operations involved in the multiplication of all the matrices is minimized. Then we need to print this order i.e. printing brackets in matrix chain multiplication problem. Consider you have 3 matrices A, B, ...

Read more

Question 23. Largest rectangular sub-matrix whose sum is 0 Problem Statement   Find the maximum size sub-matrix in a 2D array whose sum is zero. A sub-matrix is nothing but a 2D array inside of the given 2D array. So, you have a matrix of signed integers, you need to calculate the sum of sub-matrices and find the matrix with ...

Read more

Other Questions Directi

Question 24. Maximum sum of a path in a Right Number Triangle The problem “Maximum sum of a path in a Right Number Triangle” states that you are given some integers in the form of a right number triangle. Find out the maximum sum you can achieve if you start from the top and move towards the base such that you move ...

Read more

Question 25. Cutting a Rod Problem Statement   The problem “Cutting a Rod” states that you are given a rod of some particular length and prices for all sizes of rods which are smaller than or equal to the input length. That is we know the price for rods of length from 1 to n, considering ...

Read more

Question 26. Check if any two intervals overlap among a given set of intervals Problem Statement   The problem “Check if any two intervals overlap among a given set of intervals” states that you are given some set of intervals. Each interval consists of two values, one is starting time and the other is ending time. The problem statement asks to check if any of ...

Read more

Question 27. Binomial Coefficient Problem Statement   Find the Binomial Coefficient for a given value of n and k. “In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers n ≥ k ≥ 0 and is written as ” – quoted from Wikipedia. Example   n = 5, k ...

Read more

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Refresh