Infosys
Datafortune Interview Questions and Answers
Q1. Return Subsets Sum to K Problem Statement
Given an integer array 'ARR' of size 'N' and an integer 'K', return all the subsets of 'ARR' which sum to 'K'.
Explanation:
A subset of an array 'ARR' is a tuple that c...read more
Given an array and an integer, return all subsets that sum to the given integer.
Use backtracking to generate all possible subsets of the array.
For each subset, check if the sum equals the given integer 'K'.
Print the subsets that satisfy the condition.
Example: For input [1, 2, 3] and K=3, subsets [1, 2] and [3] have sum 3.
Q2. Longest Increasing Subsequence Problem Statement
Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more
Find the length of the longest strictly increasing subsequence in an array of integers.
Use dynamic programming to keep track of the longest increasing subsequence ending at each element.
Initialize an array to store the length of the longest increasing subsequence ending at each index.
Iterate through the array and update the length of the longest increasing subsequence for each element.
Return the maximum value in the array as the length of the longest increasing subsequence.
Q3. Count Inversions Problem Statement
Given an integer array ARR
of size N
containing all distinct values, determine the total number of inversions present in the array.
An inversion is defined for a pair of integ...read more
Count the total number of inversions in an integer array.
Iterate through the array and for each pair of elements, check if the conditions for inversion are met.
Use a nested loop to compare each element with all elements to its right.
Keep a count of the inversions found and return the total count at the end.
Q4. Bipartite Graph Problem
Check whether a given graph is bipartite or not. Return true
if the graph's vertices can be divided into two independent sets, ‘U’ and ‘V’, such that every edge (‘u’, ‘v’) either connect...read more
Check if a given graph is bipartite by dividing vertices into two independent sets.
Use BFS or DFS to traverse the graph and assign colors to vertices to check for bipartiteness.
If an edge connects vertices of the same color, the graph is not bipartite.
Return true if all edges connect vertices of different colors, else return false.
Q5. Boundary Traversal of Binary Tree
Given a binary tree of integers, your task is to print the boundary nodes of the binary tree in an anti-clockwise direction starting from the root node.
Note:
The boundary incl...read more
Boundary traversal of a binary tree in anti-clockwise direction starting from the root node.
Implement a function to calculate the boundary traversal of a binary tree
Include nodes from left boundary, leaf nodes, and right boundary in sequence
Ensure only unique nodes are included in the output
Print the boundary nodes separated by single spaces for each test case
Q6. what is annotation in spring boot
Annotations in Spring Boot are used to provide metadata about the application's components, helping Spring to understand how to manage them.
Annotations are used to configure Spring Boot components such as controllers, services, repositories, etc.
Annotations help Spring Boot to automatically detect and configure beans based on the annotations used.
Examples of annotations in Spring Boot include @RestController, @Service, @Repository, @Autowired, @Component, etc.
Interview Process at Datafortune
Top SDE Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month