Add office photos
Employer?
Claim Account for FREE

MAQ Software

1.9
based on 353 Reviews
Filter interviews by

10+ Infosys Interview Questions and Answers

Updated 10 Jun 2024
Popular Designations

Q1. Nth Element Of Modified Fibonacci Series

Given two integers X and Y as the first two numbers of a series, and an integer N, determine the Nth element of the series following the Fibonacci rule: f(x) = f(x - 1) ...read more

Ans.

Calculate the Nth element of a modified Fibonacci series given the first two numbers and N, with the result modulo 10^9 + 7.

  • Implement a function to calculate the Nth element of the series using the Fibonacci rule f(x) = f(x - 1) + f(x - 2)

  • Return the answer modulo 10^9 + 7 due to the possibility of a very large result

  • The series is 1-based indexed, so the first two numbers are at positions 1 and 2 respectively

Add your answer

Q2. Sort 0 1 2 Problem Statement

Given an integer array arr of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.

Input:

The first line contains an integer 'T' representing the number of...read more
Ans.

Sort an array of 0s, 1s, and 2s in linear time complexity.

  • Use three pointers to keep track of 0s, 1s, and 2s while traversing the array.

  • Swap elements based on the values encountered to sort the array in-place.

  • Time complexity of the algorithm should be O(N) where N is the size of the array.

Add your answer

Q3. Pair Sum Problem Statement

You are provided with an array ARR consisting of N distinct integers in ascending order and an integer TARGET. Your objective is to count all the distinct pairs in ARR whose sum equal...read more

Ans.

Count distinct pairs in an array whose sum equals a given target.

  • Use two pointers approach to iterate through the array and find pairs with sum equal to target.

  • Keep track of visited pairs to avoid counting duplicates.

  • Return -1 if no such pair exists with the given target.

Add your answer

Q4. Move Zeros to Left Problem Statement

Your task is to rearrange a given array ARR such that all zero elements appear at the beginning, followed by non-zero elements, while maintaining the relative order of non-z...read more

Ans.

Rearrange array to move zeros to the left while maintaining relative order of non-zero elements.

  • Iterate through the array and maintain two pointers, one for zero elements and one for non-zero elements.

  • Swap elements at the two pointers until all zeros are moved to the left.

  • Ensure to maintain the relative order of non-zero elements while rearranging the array.

Add your answer
Discover Infosys interview dos and don'ts from real experiences

Q5. Maximum Subarray Sum Problem Statement

Given an array arr of length N consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.

Explanation:

A sub...read more

Ans.

Find the sum of the subarray with the maximum sum among all subarrays in an array of integers.

  • Iterate through the array and keep track of the current sum and maximum sum.

  • Update the maximum sum whenever a new maximum subarray sum is found.

  • Handle cases where all elements are negative or the array is empty.

  • Example: For input arr = [-2, 1, -3, 4, -1], the maximum subarray sum is 4.

Add your answer

Q6. Detect and Remove Loop in Linked List

For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.

Expected Complexity:

Aim for a...read more

Ans.

Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.

  • Use Floyd's Cycle Detection Algorithm to identify the loop in the linked list.

  • Once the loop is detected, use two pointers to find the start of the loop.

  • Adjust the pointers to remove the loop and return the modified linked list.

Add your answer
Are these interview questions helpful?

Q7. Count Distinct Substrings

You are provided with a string S. Your task is to determine and return the number of distinct substrings, including the empty substring, of this given string. Implement the solution us...read more

Ans.

Count distinct substrings of a given string using trie data structure.

  • Implement a trie data structure to store all substrings of the given string.

  • Count the number of nodes in the trie to get the distinct substrings count.

  • Handle empty string case separately.

  • Example: For 'ab', distinct substrings are: '', 'a', 'b', 'ab'.

Add your answer

Q8. Equilibrium Index Problem Statement

Given an array Arr consisting of N integers, your task is to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of...read more

Ans.

Find the equilibrium index of an array where sum of elements on left equals sum on right.

  • Iterate through array to calculate prefix and suffix sums

  • Compare prefix and suffix sums to find equilibrium index

  • Return -1 if no equilibrium index is found

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Spiral Matrix Problem Statement

You are given a N x M matrix of integers. Your task is to return the spiral path of the matrix elements.

Input

The first line contains an integer 'T' which denotes the number of ...read more
Ans.

The task is to return the spiral path of elements in a given matrix.

  • Iterate through the matrix in a spiral path by adjusting the boundaries of rows and columns.

  • Keep track of the direction of traversal (right, down, left, up) to form the spiral path.

  • Handle edge cases like when the matrix is a single row or column.

  • Implement a function that takes the matrix dimensions and elements as input and returns the spiral path.

Add your answer

Q10. Minimum Travel Time Problem Statement

Mr. X plans to explore Ninja Land, which consists of N cities numbered from 1 to N and M bidirectional roads connecting these cities. Mr. X needs to select a city as the st...read more

Ans.

The task is to determine the minimum time required to visit all cities and roads in Ninja Land.

  • Create a graph representation of the cities and roads.

  • Use a traversal algorithm to find the minimum time to visit all cities and roads.

  • Return -1 if it is impossible to visit all roads.

  • Consider the constraints provided in the problem statement.

  • Implement the function to calculate the minimum travel time.

Add your answer

Q11. Two Sum Of leetcode

Ans.

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

  • Use a hashmap to store the difference between the target and current element

  • Iterate through the array and check if the current element's complement exists in the hashmap

  • Return the indices of the two numbers if found

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

Interview Process at Infosys

based on 2 interviews
Interview experience
5.0
Excellent
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

4.4
 • 30 Interview Questions
4.2
 • 20 Interview Questions
3.3
 • 18 Interview Questions
3.4
 • 13 Interview Questions
4.0
 • 11 Interview Questions
3.9
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
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