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

Power Programmer

Infosys Sp
upvote
share-icon
4 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Journey
In 2022, I successfully cleared the off-campus InfyTQ exam and achieved a top 100 rank in HackWithInfy. This accomplishment paved the way for my participation in a hackathon, where my performance in exams and interviews was evaluated. As a result, I earned an internship offer at Infosys, which eventually led to a full-time job opportunity. This journey not only demonstrated my technical proficiency but also showcased my ability to perform consistently and excel in competitive environments.
Application story
My application journey began in 2022 when I applied for InfyTQ off-campus and successfully cleared the exam. Following this achievement, I participated in HackWithInfy and secured a top 100 rank. This led to a hackathon where my exam and interview performance were evaluated, ultimately resulting in an internship offer at Infosys. The process involved applying online for InfyTQ, then progressing through HackWithInfy and culminating in interviews and the hackathon. It was a comprehensive and rewarding journey that showcased my skills and determination.
Why selected/rejected for the role?
I believe I was selected for the role due to a combination of factors. Firstly, my strong technical skills and problem-solving abilities demonstrated during InfyTQ and HackWithInfy played a crucial role. Additionally, my performance in the hackathon, where I showcased not only technical prowess but also collaboration and innovation, contributed to my selection. The entire process taught me the importance of continuous learning, adaptability, and the value of showcasing one's skills beyond traditional assessments. These experiences have been invaluable in shaping my approach to preparation and professional growth.
Preparation
Duration: 6 Months
Topics: Data structures, OOPS, Networking, computer networks, algorithms, dynamic programming, system design, competitive programming
Tip
Tip

Tip 1: Practice as many questions as you can in DSA
Tip 2: Keep all your theoretical knowledge and concepts clear.
Tip 3: Participate in CodeChef, code-forces.

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

Tip 1: Keep your resume clean and free of false information.

Tip 2: Ensure that you include projects on your resume.

Interview rounds

01
Round
Medium
Online Coding Test
Duration60 minutes
Interview date25 Jan 2022
Coding problem0

Inyftq Qualifier round
This is an optional round anyone can directly give the Hackwithinfy but I choose to give both since there are different packages for Inyftq and Hackwithinfy and Hackwithinfy has the highest package. I gave Inyftq for the practice since Hackwithinfy is considered as one of the toughest exam.

02
Round
Hard
Online Coding Test
Duration180 minutes
Interview date25 Jan 2022
Coding problem1

Inyftq Final round
This is an optional round anyone can directly give the Hackwithinfy but I choose to give both since there are different packages for Inyftq and Hackwithinfy and Hackwithinfy has the highest package. I gave Inyftq for practice since Hackwithinfy is considered as 1 of the toughest exams.

1. Optimizing Guest Satisfaction: Strategies for Minimizing Unhappiness in Hotel Service Management

Moderate
20m average time
20% success
0/80
Asked in companies
AmazonExpedia GroupInfosys Sp

In a scenario where you are the manager of a bustling hotel, overseeing the comfort and satisfaction of numerous guests, each guest brings a unique aspect to consider: their happiness level (Ci) is directly tied to the timing of their service. The happiness of a guest is inversely proportional to the time they wait for service—guests become increasingly unhappy the longer they wait. This unhappiness is quantified as |Ci – x|, where Ci represents the guest's happiness level and x denotes the time they are served.

Imagine you have N guests to attend to, with each guest's happiness value and the urgency of their service varying. Your goal is clear: minimize the total unhappiness experienced by all guests. This involves strategizing the order in which guests are served to optimize their happiness levels.

However, there are constraints to consider in this endeavor:
- The number of guests N ranges from 1 to 10^3.
- Each guest's happiness value Ci falls between 1 and N.

Given this context, delve into how you would approach this challenge as the manager, considering the intricacies of guest satisfaction and efficient time management.

Problem approach

Here is a step-by-step solution for the problem described:

1. **Input**: Obtain the input values, including the number of guests (N) and their happiness values (Ci).

2. **Sort the happiness values**: Arrange the happiness values in ascending order. This step helps minimize the total unhappiness.

3. **Initialize variables**: Set up variables such as total unhappiness (totalUnhappiness) and current time (currentTime) to keep track of the serving process.

4. **Iterate through guests**:
  - Start a loop to iterate through each guest, starting from the first (smallest happiness value).
  - For each guest:
    - Calculate their unhappiness as |Ci - currentTime|.
    - Add this unhappiness to the totalUnhappiness.
    - Increment currentTime by 1 unit as each guest takes exactly one unit of time to be served.

5. **Output**: Once all guests are served, output the totalUnhappiness, which represents the minimum total unhappiness achieved by serving all guests in an optimized order.

Let's illustrate this with an example:
Input: 4 2 2 3 3

1. Sort the happiness values: 2 2 3 3
2. Initialize totalUnhappiness = 0 and currentTime = 0
3. Iterate through guests:
  - Guest 1 (happiness 2): |2 - 0| = 2, totalUnhappiness = 2, currentTime = 1
  - Guest 2 (happiness 2): |2 - 1| = 1, totalUnhappiness = 2 + 1 = 3, currentTime = 2
  - Guest 3 (happiness 3): |3 - 2| = 1, totalUnhappiness = 3 + 1 = 4, currentTime = 3
  - Guest 4 (happiness 3): |3 - 3| = 0, totalUnhappiness = 4 + 0 = 4, currentTime = 4
4. Output: Total unhappiness = 4

This step-wise solution ensures an optimized order of serving guests to minimize total unhappiness.

Try solving now
03
Round
Hard
Online Coding Test
Duration180 minutes
Interview date25 Feb 2022
Coding problem3

1. Counting Attacking Queen Pairs on a Chessboard

Hard
55m average time
35% success
0/120
Asked in companies
Thought WorksTwitterAdobe

You are given an integer N representing the size of a chessboard, and the positions of M queens on this chessboard. Find the number of pairs of queens that are in an attacking position.

Input Format:
- The first line contains an integer, N, representing the size of the chessboard.
- The second line contains an integer, M, denoting the number of queens.
- Each of the next M lines contains two space-separated integers, representing the row and column coordinates of each queen.

Output Format:
- Print the number of pairs of queens that are in an attacking position. Since the answer can be large, return it modulo 10^9 + 7.

Constraints
- 1 <= N <= 10^6
- 1 <= M <= 10^5
- 1 <= Ai, Bi <= N, where Ai represents the row coordinate and Bi represents the column coordinate of the ith queen.

Try solving now

2. Minimum Operations for String Transformation

Moderate
26m average time
0/80
Asked in companies
SamsungAppleMicrosoft

Given two strings A and B, the task is to convert A to B if possible. The only operation allowed is to put any character from A and insert it at the front. Find if it’s possible to convert the string. If yes, then output the minimum no. of operations required for transformation.

Problem approach

We declare a HashMap to store the frequency map.
We store the character of string 1 in the map and then while traversing string 2, we erase the characters if the map is empty at the end that means the characters in both strings are the same and we can continue, or else we return -1.
We make a variable res and point two pointers i and j to the last of both strings and start traversing from back.
As soon as see an ith character that doesn’t match with the jth character, we start increasing res by 1 until again both the characters are the same.
At last, we return the res.

Try solving now

3. Sum of XOR Values in a Tree

Moderate
10m average time
90% success
0/80
Asked in companies
UberRubrik, Inc.Urban Company (UrbanClap)

You are given a tree with N nodes represented by an array P, where each element P[i] denotes the parent node of node i. Additionally, each node i has a value given by the array A. The XOR value of an element is defined as the XOR of all the elements in its subtree, including itself.

Write a function to find the sum of XOR values of all nodes in the tree modulo 10^9+7.

Problem approach

Here's a stepwise solution for finding the sum of the XOR values of all nodes in a tree:

1. Create Tree Structure:
  - Initialize a list of lists or a dictionary to represent the tree structure based on the parent-child relationships defined in array P.

3. Calculate XOR Values Recursively:
  - Implement a recursive function to calculate the XOR value for each node and its subtree.
  - Start with the root node (node 0) and recursively process each node:
    - For each node, calculate its XOR value by XORing its value (A[i]) with the XOR values of its children.
    - Recursively call the function for each child node to calculate their XOR values.

4. Sum XOR Values:
  - Traverse the tree and sum up the XOR values of all nodes to get the total sum of XOR values in the tree.

5. Modulo Operation:
  - After computing the sum of XOR values, perform a modulo operation with 10^9+7 to ensure the result stays within the specified range.

6. Return Result:
  - Return the final sum of XOR values modulo 10^9+7 as the result.

Try solving now
04
Round
Medium
Face to Face
Duration60 minutes
Interview date25 Aug 2022
Coding problem4

1. Range Sum Calculation in an Array

Easy
15m average time
80% success
0/40
Asked in companies
OptumSamsungNokia

Problem Statement:

Given an array of numbers [1, 2, 3, 4, 5, 6], find the sum of elements with specific indices within a given range.

Write a function to calculate the sum of elements in the array from index i to index j (inclusive), where i and j are specified as input.

Input Format:

The input consists of the following:

• An array of integers representing the elements: [1, 2, 3, 4, 5, 6]
• Two integers i and j, representing the start and end indices of the range.

Output Format:

Print the sum of elements in the array from index i to index j (inclusive).

Example:

Input:

Array: [1, 2, 3, 4, 5, 6]
Start Index: 1
End Index: 4

Output:

Sum: 14

Problem approach

Explanation:

In the given array [1, 2, 3, 4, 5, 6], the elements from index 1 to index 4 are [2, 3, 4, 5]. The sum of these elements is 2 + 3 + 4 + 5 = 14.

Code Snippet:

def calculateSumInRange(arr, start, end):
   if start < 0 or end >= len(arr) or start > end:
       return "Invalid range"

   return sum(arr[start:end+1])

if __name__ == "__main__":
   arr = [1, 2, 3, 4, 5, 6]
   start = 1
   end = 4

   result = calculateSumInRange(arr, start, end)
   print("Sum:", result)

This code calculates the sum of elements in the array within the specified range [start, end] and handles invalid ranges by returning an appropriate message. Adjust the input array and range values based on the actual problem requirements.

Try solving now

2. Two Sum Problem:

Easy
10m average time
90% success
0/40
Asked in companies
Chegg Inc.FacebookAmazon

You are given an array of integers and a target sum. Write a function to find two numbers in the array that add up to the target sum. If such a pair exists, return their indices. If no pair is found, return “No solution”.

Input Format:

• An array of integers: [1, 5, 3, 7, 9]
• Target sum: 10

Output Format:

• If a pair is found: Indices of the two numbers that add up to the target sum.
• If no pair is found: “No solution”.

Example:

Input:

Array: [1, 5, 3, 7, 9]
Target Sum: 10

Output:

Indices: [1, 3]  # Numbers at indices 1 and 3 (5 and 7) add up to 10.

Problem approach

Here are the steps to solve the Two Sum problem efficiently:

1. **Input Preparation**:
  - Given an array of integers `nums` and a target sum `target`.

2. **Create a HashMap**:
  - Initialize an empty HashMap to store the indices of elements.

3. **Iterate Through Array**:
  - Iterate through each element in the array `nums` with index `i`.

4. **Check Complement**:
  - Calculate the complement as `complement = target - nums[i]`.
  - Check if the complement exists in the HashMap:
    - If yes, return the indices `[hashMap[complement], i]`.
    - If not, add the current element and its index to the HashMap.

5. **Return "No Solution"**:
  - If the loop completes without finding a valid pair, return "No solution".

6. **Code Implementation** (Python Example):

```python
def twoSum(nums, target):
   # Initialize HashMap to store indices
   hashMap = {}
   
   # Iterate through array
   for i in range(len(nums)):
       complement = target - nums[i]
       # Check if complement exists in HashMap
       if complement in hashMap:
           return [hashMap[complement], i]
       # Add current element and index to HashMap
       hashMap[nums[i]] = i
   
   # No solution found
   return "No solution"

# Example usage
nums = [2, 7, 11, 15]
target = 9
result = twoSum(nums, target)
print("Indices:", result)  # Output: Indices: [0, 1] (nums[0] + nums[1] = 9)
```

This implementation uses a HashMap to efficiently find the two numbers that add up to the target sum by checking for their complements. Adjust the input array `nums` and target sum `target` based on the actual problem requirements.

Try solving now

3. Three Sum Problem:

Moderate
15m average time
85% success
0/80
Asked in companies
IntuitSamsungGrofers

You are given an array of integers and a target sum. Write a function to find three numbers in the array that add up to the target sum. If such a triplet exists, return their indices. If no triplet is found, return “No solution”.

Input Format:

• An array of integers: [3, 2, 4, 8, 5, 9]
• Target sum: 15

Output Format:

• If a triplet is found: Indices of the three numbers that add up to the target sum.
• If no triplet is found: “No solution”.

Example:

Input:

Array: [3, 2, 4, 8, 5, 9]
Target Sum: 15

Output:

Indices: [0, 2, 3]  # Numbers at indices 0, 2, and 3 (3, 4, and 8) add up to 15.

Adjust the input array and target sum based on the actual problem requirements.

Problem approach

Here are the steps to solve the Three Sum problem:

1. **Input Preparation**:
  - Given an array of integers `nums` and a target sum `target`.

2. **Sort the Array**:
  - Sort the array `nums` in non-decreasing order. This step is crucial for optimizing the algorithm.

3. **Initialize Result List**:
  - Initialize an empty list `result` to store the triplets that sum up to the target.

4. **Iterate Through Array**:
  - Iterate through each element in the sorted array `nums` up to the third-to-last element (to leave room for two pointers).

5. **Two Pointers Approach**:
  - For each element `nums[i]`, initialize two pointers `left = i + 1` and `right = len(nums) - 1`.
  - While `left < right`, perform the following steps:
    - Calculate the current sum as `current_sum = nums[i] + nums[left] + nums[right]`.
    - If `current_sum` equals `target`, add the triplet `[nums[i], nums[left], nums[right]]` to the `result` list.
    - If `current_sum` is less than `target`, increment `left` to move towards larger values.
    - If `current_sum` is greater than `target`, decrement `right` to move towards smaller values.

6. **Avoid Duplicates**:
  - While iterating through `nums`, skip duplicate elements to avoid duplicate triplets in the result.

7. **Return Result**:
  - After completing the iterations, return the `result` list containing all valid triplets that sum up to the target.

 

This implementation uses the two-pointers approach along with sorting and skipping duplicates to efficiently find all triplets in the array `nums` that sum up to the target sum `target`. Adjust the input array `nums` and target sum `target` based on the actual problem requirements.

Try solving now

4. Database Management System (DBMS) Question:

 

Consider a database schema for a university that includes the following tables:

1. **Students**:
  - student_id (Primary Key)
  - name
  - email
  - department_id (Foreign Key referencing Departments table)

2. **Departments**:
  - department_id (Primary Key)
  - name
  - location

3. **Courses**:
  - course_id (Primary Key)
  - name
  - credits
  - department_id (Foreign Key referencing Departments table)

Write SQL queries for the following scenarios:

1. Retrieve the names and emails of students who are enrolled in courses with more than 3 credits.
2. Update the location of the department with department_id = 101 to 'New Building'.
3. Insert a new course named 'Database Management' with 4 credits into the Computer Science department.
4. Delete all students from the 'Computer Science' department.

Your queries should be in standard SQL syntax.

Here's your problem of the day

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

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
8518 views
0 comments
0 upvotes
Analytics Consultant
3 rounds | 10 problems
Interviewed by ZS
907 views
0 comments
0 upvotes
company logo
SDE - Intern
1 rounds | 3 problems
Interviewed by Amazon
3319 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 6 problems
Interviewed by Expedia Group
2580 views
0 comments
0 upvotes