Add office photos
Directi logo
Employer?
Claim Account for FREE

Directi

4.1
based on 59 Reviews
Video summary
Filter interviews by
Software Developer
Skills
Clear (1)

Directi Software Developer Interview Questions and Answers

Updated 5 Feb 2024

Q1. Duplicate Elements in Array

You are provided with an array or list called ARR, consisting of N integers. These integers fall within the range from 0 to N - 1. Some elements in this array may appear more than on...read more

Ans.

Identify duplicate elements in an array of integers within the range from 0 to N - 1.

  • Iterate through the array and keep track of seen elements using a hash set.

  • If an element is already in the set, it is a duplicate and can be added to the result.

  • Return the list of duplicate elements found in the array.

  • Example: For input [1, 3, 1, 3, 4], output should be ['1', '3'].

Add your answer
right arrow

Q2. Leaf Nodes Retrieval from Binary Tree

Given a binary tree, implement a function that returns a list of leaf nodes following their appearance from left to right. If leaf nodes are equidistant from the leftmost n...read more

Ans.

Implement a function to retrieve leaf nodes from a binary tree in left-to-right order.

  • Traverse the binary tree in a depth-first manner, keeping track of leaf nodes encountered.

  • Store leaf nodes in a list while traversing the tree.

  • If leaf nodes are equidistant from the leftmost node, prefer the node at a lesser depth.

  • Return the list of leaf nodes in the order they appear from left to right.

Add your answer
right arrow

Q3. Dijkstra's Algorithm Problem Statement

Given an undirected graph with 'V' vertices (labeled 0, 1, ..., V-1) and 'E' edges, where each edge connects two nodes ('X', 'Y') and has a weight that denotes the distanc...read more

Ans.

Dijkstra's algorithm is used to find the shortest path distance from a source node to all other nodes in a graph.

  • Implement Dijkstra's algorithm to find the shortest path distances from node 0 to all other nodes in the graph.

  • Use a priority queue to efficiently select the next node with the shortest distance.

  • Initialize distances to all nodes as infinity except for the source node which is 0.

  • Update distances to neighboring nodes if a shorter path is found.

  • Repeat the process unti...read more

Add your answer
right arrow

Q4. Exclusive Time of Functions

We are executing a program containing 'N' functions on a single-threaded CPU. Each function has a unique 'ID' between 0 and (N-1). Each time a function starts or ends, a log is recor...read more

Ans.

Calculate exclusive time of functions based on logs of function start and end times.

  • Parse the input logs to calculate exclusive time for each function ID.

  • Use a stack to keep track of function start times and calculate exclusive time when function ends.

  • Iterate through the logs and update exclusive time for each function ID accordingly.

Add your answer
right arrow
Discover Directi interview dos and don'ts from real experiences

Q5. Box Stacking Problem Statement

Consider you are provided with 'n' different types of rectangular 3D boxes. For each type of box, you have three separate arrays: height, width, and length that define the dimensi...read more

Ans.

The task is to stack different types of rectangular 3D boxes to achieve the maximum possible height.

  • Iterate through all possible rotations of each box type.

  • Sort the boxes based on their base dimensions in non-increasing order.

  • Use dynamic programming to find the maximum height achievable by stacking the boxes.

  • Consider the constraints while implementing the solution.

  • Example: For input [3, [4, 1, 4], [6, 2, 5], [7, 3, 6]], the output should be 15.

Add your answer
right arrow

Q6. Find Triplets with Given Sum Problem Statement

Given an array ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a given integer K.

Explanation:

An arra...read more

Ans.

The task is to find all distinct triplets in an array that sum up to a given integer.

  • Iterate through the array and use a nested loop to find all possible triplets.

  • Use a set to store unique triplets and avoid duplicates.

  • Check if the sum of the triplet equals the target sum.

  • Return the list of valid triplets or -1 if no such triplet exists.

Add your answer
right arrow

Q7. Stock Buy and Sell Problem Statement

Given an array/list 'prices' where the elements represent yesterday's stock prices at each minute, determine the maximum profit possible from a single buy and sell action.

Y...read more

Ans.

Given an array of stock prices, find the maximum profit from a single buy and sell action.

  • Iterate through the array and keep track of the minimum price seen so far and the maximum profit achievable.

  • Calculate the profit by subtracting the current price from the minimum price seen so far.

  • If the profit is negative, set it to 0 as we can't sell without buying first.

Add your answer
right arrow

Q8. Maximum Sum Subarray Problem Statement

Given an array of integers, find the maximum sum of any contiguous subarray within the array.

Example:

Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
Explanation:

Th...read more

Ans.

Find the maximum sum of any contiguous subarray within an array in O(N) time complexity.

  • Use Kadane's algorithm to find the maximum sum subarray in O(N) time complexity

  • Initialize two variables: max_sum and current_sum to track the maximum sum subarray

  • Iterate through the array and update current_sum by adding the current element or starting a new subarray

  • Update max_sum if current_sum becomes greater than max_sum

Add your answer
right arrow

Q9. Occurrence of X in a Sorted Array Problem Statement

Given a sorted array of integers of size N and an integer X, determine the total number of occurrences of X in the array.

Input:

The first line of the input c...read more
Ans.

Count occurrences of a given integer in a sorted array.

  • Use binary search to find the first and last occurrence of X in the array.

  • Calculate the total occurrences by subtracting the indices and adding 1.

  • Handle edge cases like X not present in the array.

  • Time complexity can be O(log N) using binary search.

Add your answer
right arrow
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Directi Software Developer

based on 3 interviews
Interview experience
4.0
Good
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

IBM Logo
4.0
 • 49 Interview Questions
Siemens Logo
4.1
 • 25 Interview Questions
Hike Logo
3.6
 • 23 Interview Questions
HARMAN Logo
3.7
 • 12 Interview Questions
View all
Recently Viewed
INTERVIEWS
Directi
5.6k top interview questions
INTERVIEWS
MAYBRIGHT VENTURES PRIVATE LIMITED, Kolkata
No Interviews
INTERVIEWS
DRC Systems
No Interviews
INTERVIEWS
Eversendai
No Interviews
INTERVIEWS
Publicis
No Interviews
CAMPUS PLACEMENT
Anna University
INTERVIEWS
Credgenics
No Interviews
INTERVIEWS
Eversendai
No Interviews
INTERVIEWS
Eversendai
No Interviews
INTERVIEWS
Publicis
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter