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

Specialist Programmer

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

Interview preparation journey

expand-icon
Preparation
Duration: 3 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

Application process
Where: Company Website
Eligibility: 6.5 CGPA
Resume Tip
Resume tip

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

Interview rounds

01
Round
Medium
Online Coding Test
Duration180 minutes
Interview date27 Feb 2021
Coding problem4

There was 1 round of 180 minutes which contains of 3-4 questions from DSA

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. Longest Repeating Substring

Moderate
10m average time
90% success
0/80
Asked in companies
CIS - Cyber InfrastructureIBMMakeMyTrip

You are given a string 'str' of length 'N'. You can perform at most 'k' operations on this string. In one operation, you can choose any character of the string and change it to any other uppercase English alphabet character.


Return the length of the longest substring containing same characters after performing the above operations.


For example :

Input:
str="AABC"  k=1

Output:3

Explanation: Replace 'B' with 'A', we will get "AAAC" and the longest substring with same character is "AAA" of length 3.
Problem approach

check for each character of English alphabet (both upper and lower cases one by one). Basically look for maximum length of sub-string that can be formed by each character and whichever character will form the sub-string of maximum length then that length will be our answer.

1) check for maximum length of sub-string that can be formed by every character in a set of 52 characters (From ‘A’ to ‘Z’ and from ‘a’ to ‘z’).
2) For doing this we traverse whole string and whenever we find a different character, we increase the count.
If count becomes greater than k (at right index), we again start from 0th index and if we found different character we will decrease the count.
3) When count will be equal to k (at left index) then at that point the length will be rightIndex-leftIndex+1.
4) repeat this process until we reach at the end of string and at that point we will return the maximum length.
5) do this for all characters and finally return the maximum length.

Try solving now

3. Is Graph Bipartite?

Moderate
0/80
Asked in companies
FacebookSamsungDirecti

You are given an undirected graph consisting of ‘N’ nodes from 0 to ‘N’ - 1. You are given a list ‘EDGES’ of size ‘M’, consisting of all the edges of this undirected graph. Determine whether the given graph is Bipartite or not.

Note:
The graph has no self-edges, no parallel edges.

The graph may not be connected.

A graph is bipartite if the nodes of the graph can be partitioned into two independent sets A and B such that every edge in the graph connects a node in set A and a node in set B.
For Example,
If ‘N’ = 4, ‘M’ = 5, edgeList = [ [0, 1],[0, 3],[1, 2] ].

Here, you can see that the graph is bipartite as we can divide the nodes in two sets as follows:
setA = [0, 2].
setB = [1, 3].

In the graph, you can see that every edge in the graph connects a node in set A and a node in set B.
Hence, the output is “Yes”.
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 color to the source vertex (putting into set U). 
2. Color all the neighbors with BLUE color (putting into set V). 
3. Color all neighbor’s neighbor with RED color (putting into set U). 
4. This way, assign color to all vertices such that it satisfies all the constraints of m way coloring problem where m = 2. 
5. While assigning colors, if we find a neighbor which is colored with same color as current vertex, then the graph cannot be colored with 2 vertices (or graph is not Bipartite)

Try solving now

4. Trapping Rain Water

Moderate
15m average time
80% success
0/80
Asked in companies
SalesforcePayPalHexaware Technologies

You have been given a long type array/list 'arr’ of size 'n’.


It represents an elevation map wherein 'arr[i]’ denotes the elevation of the 'ith' bar.



Note :
The width of each bar is the same and is equal to 1.
Example:
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].

Output: 10

Explanation: Refer to the image for better comprehension:

Alt Text

Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
Problem approach

Traverse every array element and find the highest bars on the left and right sides. Take the smaller of two heights. The difference between the smaller height and the height of the current element is the amount of water that can be stored in this array element.

Follow the steps mentioned below to implement the idea:

Traverse the array from start to end:
For every element: 
Traverse the array from start to that index and find the maximum height (a) and 
Traverse the array from the current index to the end, and find the maximum height (b).
The amount of water that will be stored in this column is min(a,b) – array[i], add this value to the total amount of water stored
Print the total amount of water stored.

Try solving now
02
Round
Easy
Video Call
Duration60 minutes
Interview date11 Mar 2021
Coding problem8

1. 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().

Try solving now

2. First Missing Positive

Moderate
18m average time
84% success
0/80
Asked in companies
SamsungAmazonOYO

You are given an array 'ARR' of integers of length N. Your task is to find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can have negative numbers as well.

For example, the input [3, 4, -1, 1] should give output 2 because it is the smallest positive number that is missing in the input array.

Problem approach

In this problem, I have created a list full of 0’s with size of the max() value of our given array. Now, whenever I encounter any positive value in original array, I change the index value of our list to 1. After that I , we simply iterate through our modified list, the first 0 we encounter, its (index value + 1) should be the answer since index in python starts from 0.

Try solving now

3. Merge Sort

Easy
15m average time
85% success
0/40
Asked in companies
Wells FargoThought WorksAccenture

Given a sequence of numbers ‘ARR’. Your task is to return a sorted sequence of ‘ARR’ in non-descending order with help of the merge sort algorithm.

Example :

Merge Sort Algorithm -

Merge sort is a Divide and Conquer based Algorithm. It divides the input array into two-parts, until the size of the input array is not ‘1’. In the return part, it will merge two sorted arrays a return a whole merged sorted array.

subsequence

The above illustrates shows how merge sort works.
Note :
It is compulsory to use the ‘Merge Sort’ algorithm.
Try solving now

4. Operating System Question

what is deadlock?

5. Operating System Question

What is a bootstrap program in OS?

6. DBMS Question

What are acid properties?

7. DBMS Question

Difference between delete and trucate.

8. DBMS Question

Different types of Joins in Sql

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
Specialist Programmer
2 rounds | 4 problems
Interviewed by Infosys private limited
924 views
0 comments
0 upvotes
Specialist Programmer
2 rounds | 3 problems
Interviewed by Infosys private limited
875 views
0 comments
0 upvotes
Specialist Programmer
2 rounds | 11 problems
Interviewed by Infosys private limited
1238 views
0 comments
0 upvotes
Specialist Programmer
2 rounds | 4 problems
Interviewed by Infosys private limited
131 views
0 comments
0 upvotes