Infosys private limited interview experience Real time questions & tips from candidates to crack your interview

SDE

Infosys private limited
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Data Structures, DBMS ,OOPS ,System Design, Algorithms, Dynamic Programming.
Tip
Tip

Tip 1 - Practice At least 250 Questions of DS algo
Tip 2 - Do at least 2 application based projects
Tip 3 - Practice questions with optimized approaches

Application process
Where: Campus
Eligibility: 60% in 12th & above 65% in B.tech
Resume Tip
Resume tip

Tip 1 : Have some application based projects on resume.
Tip 2 : Do not put false things on resume.
Tip 3 : Project should clear and crisp

Interview rounds

01
Round
Hard
Online Coding Test
Duration180 minutes
Interview date17 Mar 2022
Coding problem3

There was 1 round of 180 minutes which contains of 3 questions from DSA. the two question was of medium level but one question is of neither difficult nor medium level question based on tree

1. Longest Increasing Subsequence

Moderate
30m average time
65% success
0/80
Asked in companies
ShareChatFacebookMorgan Stanley

For a given array with N elements, you need to find the length of the longest subsequence from the array such that all the elements of the subsequence are sorted in strictly increasing order.

Strictly Increasing Sequence is when each term in the sequence is larger than the preceding term.

For example:
[1, 2, 3, 4] is a strictly increasing array, while [2, 1, 4, 3] is not.
Problem approach

As there are many subproblems in the recursive solution which are solved again and again. So this problem has Overlapping Substructure property and re-computation of same subproblems can be avoided by either using Memoization or Tabulation.

The simulation of approach will make things clear: 

Input : arr[] = {3, 10, 2, 11}
LIS[] = {1, 1, 1, 1} (initially)

Iteration-wise simulation : 

arr[2] > arr[1] {LIS[2] = max(LIS [2], LIS[1]+1)=2}
arr[3] < arr[1] {No change}
arr[3] < arr[2] {No change}
arr[4] > arr[1] {LIS[4] = max(LIS [4], LIS[1]+1)=2}
arr[4] > arr[2] {LIS[4] = max(LIS [4], LIS[2]+1)=3}
arr[4] > arr[3] {LIS[4] = max(LIS [4], LIS[3]+1)=3}


Complexity Analysis: 

Time Complexity: O(n2). 
As nested loop is used.
Auxiliary Space: O(n). 
Use of any array to store LIS values at each index

Try solving now

2. Bipartite Graph

Moderate
50m average time
50% success
0/80
Asked in companies
UberWalmarteBay

Given a graph, check whether the graph is bipartite or not. Your function should return true if the given graph's vertices can be divided into two independent sets, ‘U’ and ‘V’ such that every edge (‘u’, ‘v’) either connects a vertex from ‘U’ to ‘V’ or a vertex from ‘V’ to ‘U’.

You are given a 2D array ‘edges’ which contains 0 and 1, where ‘edges[i][j]’ = 1 denotes a bi-directional edge from ‘i’ to ‘j’.

Note:
If edges[i][j] = 1, that implies there is a bi-directional edge between ‘i’ and ‘j’, that means there exists both edges from ‘i’ to ‘j’ and to ‘j’ to ‘i’.

For example

Given:
‘N’ = 3
‘edges’ = [[0, 1, 1], [0, 0, 1], [0,0,0]]. 

Problem approach

Following is a simple algorithm to find out whether a given graph is Bipartite or not using Breadth First Search (BFS). 
1. Assign RED colour to the source vertex (putting into set U). 
2. Colour all the neighbours with BLUE colour (putting into set V). 
3. Colour all neighbour’s neighbour with RED colour (putting into set U). 
4. This way, assign colour to all vertices such that it satisfies all the constraints of m way colouring problem where m = 2. 
5. While assigning colours, if we find a neighbour which is coloured with same colour as current vertex, then the graph cannot be coloured with 2 vertices (or graph is not Bipartite)

Try solving now

3. Count Inversions

Moderate
40m average time
55% success
0/80
Asked in companies
MakeMyTripMicrosoftHewlett Packard Enterprise

For a given integer array/list 'ARR' of size 'N' containing all distinct values, find the total number of 'Inversions' that may exist.

An inversion is defined for a pair of integers in the array/list when the following two conditions are met.

A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:

1. 'ARR[i] > 'ARR[j]' 
2. 'i' < 'j'

Where 'i' and 'j' denote the indices ranging from [0, 'N').
Problem approach

The idea is to use a method similar to the merge sort algorithm. Like merge sort, divide the given array into two parts. For each left and right half, count the inversions, and at the end, sum up the inversions from both halves to get the resultant inversions.

Approach ; -

Suppose the number of inversions in the left half and right half of the array (let be inv1 and inv2); what kinds of inversions are not accounted for in Inv1 + Inv2? The answer is – the inversions that need to be counted during the merge step. Therefore, to get the total number of inversions that needs to be added are the number of inversions in the left subarray, right subarray, and merge().

Algorithm

The idea is similar to merge sort, divide the array into two equal or almost equal halves in each step until the base case is reached.
Create a function merge that counts the number of inversions when two halves of the array are merged, create two indices i and j, i is the index for the first half, and j is an index of the second half. if a[i] is greater than a[j], then there are (mid – i) inversions. because left and right subarrays are sorted, so all the remaining elements in left-subarray (a[i+1], a[i+2] … a[mid]) will be greater than a[j].
Create a recursive function to divide the array into halves and find the answer by summing the number of inversions is the first half, the number of inversion in the second half and the number of inversions by merging the two.
The base case of recursion is when there is only one element in the given half.
Print the answer

Try solving now
02
Round
Medium
Face to Face
Duration50 minutes
Interview date4 Apr 2022
Coding problem2

In interview I was asked about some question related to Data structures , DBMS . Some output based question was asked and 2 coding problems was given to solve.

1. Return Subsets Sum to K

Moderate
40m average time
75% success
0/80
Asked in companies
Thought WorksMicrosoftUber

Given an integer array 'ARR' of size 'N' and an integer 'K', return all the subsets of 'ARR' which sum to 'K'.

Subset of an array 'ARR' is a tuple that can be obtained from 'ARR' by removing some (possibly all) elements of 'ARR'.

Note :
The order of subsets is not important. 

The order of elements in a particular subset should be in increasing order of the index.
Problem approach

Recursively generate all the subsets and keep track of the sum of the elements in the current subset.

Subsets can be generated in the following way. For every element of the array, there are 2 options: 

Include the element in the current subset : If we include the element in the current subset, then we decrease the value of ‘K’ by the value of the element.
Do not include the element in the current subset : There is no effect on the value of ‘K’ and we can simply move onto the next element.
In any step, if the value of ‘K’ becomes 0, then we have found a subset which sums to ‘K’. We store all these subsets and return them.

Try solving now

2. Boundary Traversal

Hard
20m average time
85% success
0/120
Asked in companies
Info Edge India (Naukri.com)SAP LabsGoldman Sachs

You are given a binary tree having 'n' nodes.


The boundary nodes of a binary tree include the nodes from the left and right boundaries and the leaf nodes, each node considered once.


Figure out the boundary nodes of this binary tree in an Anti-Clockwise direction starting from the root node.


Example :
Input: Consider the binary tree A as shown in the figure:

alt text

Output: [10, 5, 3, 7, 18, 25, 20]

Explanation: As shown in the figure

The nodes on the left boundary are [10, 5, 3]

The nodes on the right boundary are [10, 20, 25]

The leaf nodes are [3, 7, 18, 25].

Please note that nodes 3 and 25 appear in two places but are considered once.
Problem approach

I was not able to solve this question but the approach is given below.

The boundary traversal of a binary tree can be broken down into 4 parts. These parts are given in the same order as they are present in the traversal-



The root node - The root node will always be our first node in the whole boundary traversal.

The left boundary - The left most nodes of the left subtree are also included in the boundary traversal, so we will process them next except for the leaf node as it will be processed in our next part. We can use recursion for this and traverse for only left child until a leaf node is encountered. If the left child is not present we recurse for the right child.

The leaf Nodes - The leaf nodes of the binary tree will be processed next. We can use a simple inorder traversal for that. Inorder traversal will make sure that we process leaf nodes from left to right.

The right boundary - The right most nodes of the right subtree will be processed at last in reverse order except for the leaf node as it is already processed in the previous part. For this, we can use recursion in a postorder manner and traverse for the right child only until we encounter a leaf node. If the right child is not present we will recurse for the left child. The postorder recursion will make sure that we traverse the right boundary in reverse order

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

To make an AI less repetitive in a long paragraph, you should increase:

Choose another skill to practice
Similar interview experiences
System Engineer Specialist
2 rounds | 4 problems
Interviewed by Infosys private limited
1453 views
0 comments
0 upvotes
SDE
2 rounds | 5 problems
Interviewed by Infosys private limited
1102 views
0 comments
0 upvotes
SDE
2 rounds | 4 problems
Interviewed by Infosys private limited
0 views
0 comments
0 upvotes
Software Engineer
3 rounds | 3 problems
Interviewed by Infosys private limited
1174 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE
3 rounds | 6 problems
Interviewed by PhonePe
0 views
0 comments
0 upvotes
company logo
SDE
2 rounds | 6 problems
Interviewed by Tata Consultancy Services (TCS)
2132 views
0 comments
0 upvotes
company logo
SDE
5 rounds | 8 problems
Interviewed by Mathworks
1203 views
0 comments
0 upvotes