Premium Employer
Infosys
based on 34.5k Reviews
Company Overview
Associated Companies
Company Locations
Top 3.7k Interview Questions and Answers 2024
Updated on 9 Sep 2024
Q1. Count Ways To Reach The N-th Stairs You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are supposed to return the number of distinct ways in which you can climb from the 0th step to Nth step. Example : N=3 We can climb one step at a time i.e. {(0, 1) ,(1, 2),(2,3)} or we can climb the first two-step and then one step i.e. {(0,2),(1, 3)} or we can climb first one step and then two step i.e. {(0,1), (1,3)}. Input format : The first line contains an integer 'T', which denotes the number of test cases or queries to be run. Then the test cases follow. The first and the only argument of each test case...read more
asked in
System Engineer InterviewView Answers (7)
Q2. Distinct Strings With Odd and Even Swapping Allowed You are given an array of strings. Your task is to find the number of unique strings. A string is considered unique if it cannot be formed from any other string, present in the array, even after applying the following operations any number of times and in any order: 1. Swapping two characters present at odd indices. 2. Swapping two characters present at even indices. Note: Strings contain only lowercase English alphabets. Example: Let the array of strings be [“abcd”, “cbad”, “bdac”, “adcb”]. From the given array, strings “abcd”, “cbad”, and “adcb” can be transformed into one another by applying the given operations. But “bdac” cannot be transformed into any other ...read more
asked in
System Engineer InterviewView Answers (4)
Q3. Maximum Subarray Sum You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the subarray (including empty subarray) having maximum sum among all subarrays. A subarray is a contiguous segment of an array. In other words, a subarray can be formed by removing 0 or more integers from the beginning, and 0 or more integers from the end of an array. Note : The sum of an empty subarray is 0. Input Format : The first line of input contains an integer N, representing the length of the array. The second line of input contains N single space-separated integers, denoting the elements of the array. Output Format : In the only output line, output the maximum subarray sum. Note : You are no...read more
asked in
System Engineer InterviewView Answers (7)
Discover interview dos and don'ts from real experiences
Q4. Pair Sum You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'. Note: Each pair should be sorted i.e the first value should be less than or equals to the second value. Return the list of pairs sorted in non-decreasing order of their first value. In case if two pairs have the same first value, the pair with a smaller second value should come first. Input Format: The first line of input contains two space-separated integers 'N' and 'S', denoting the size of the input array and the value of 'S'. The second and last line of input contains 'N' space-separated integers, denoting the elements of t...read more
asked in
System Engineer InterviewView Answers (5)
Q5. Valid Parenthesis You're given string ‘STR’ consisting solely of “{“, “}”, “(“, “)”, “[“ and “]” . Determine whether the parentheses are balanced. Input Format: The first line contains an Integer 'T' which denotes the number of test cases or queries to be run. Then the test cases follow. The first and the only line of input of each test case contains a string, as described in the task. Output format : For each test case, the first and the only line of output prints whether the string or expression is balanced or not. The output of every test case is printed in a separate line. Note: You are not required to print anything explicitly. It has already been taken care of. Just implement the given function. Constraints...read more
asked in
System Engineer InterviewView Answers (2)
Q6. Khaled has an array A of N elements. It is guaranteed that N is even. He wants to choose at most N/2 elements from array A. It is not necessary to choose consecutive elements. Khaled is interested in XOR of all the elements he chooses. Here, XOR denotes the bitwise XOR operation....read more
asked in
System Engineer InterviewView Answers (2)
Share interview questions and help millions of jobseekers 🌟
Q7. Print All Subsets You are given an array ‘arr’ of ‘N’ distinct integers. Your task is to print all the non-empty subsets of the array. Note: elements inside each subset should be sorted in increasing order. But you can print the subsets in any order, you don’t have to specifically sort them. Input Format : The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows The first line of each test case contains a single integers ‘N’ denoting the length of the array. The second line of each test case contains ‘N’ integers denoting the array elements. Output Format : For each test case print each subset in a separate line. The subsets can be print in any order. Output for ea...read more
asked in
System Engineer InterviewView Answers (3)
Q8. Quick Sort You are given an array of integers. You need to sort the array in ascending order using quick sort. Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the array into two parts i.e, left and right. The left part contains the numbers smaller than the pivot element and the right part contains the numbers larger than the pivot element. Then we recursively sort the left and right parts of the array. Example: Let the array = [ 4, 2, 1, 5, 3 ] Let pivot to be the rightmost number. After the 1st level partitioning the array will be { 2, 1, 3, 4, 5 } as 3 was the pivot. After 2nd level partitioning the array will be { 1, 2, 3, 4, 5 } as 1 was the pivot for the left part an...read more
asked in
System Engineer InterviewView Answers (4)
Q10. 1. what is the difference between exception and error. How did u solve the errors in the code deployment?...read more
asked in
Software Developer InterviewView Answers (16)
Q11. Generate all parenthesis You are given an integer ‘N’, your task is to generate all combinations of well-formed parenthesis having ‘N’ pairs. You are task is to generate all possible valid sets of parenthesis that can be formed with a given number of pairs. A parenthesis is called well-formed if it is balanced i.e. each left parenthesis has a matching right parenthesis and the matched pairs are well nested. For Example: For ‘N’ = 3, All possible combinations are: ((())) (()()) (())() ()(()) ()()() Input Format: Input consists of a single line containing a single integer ‘N’, representing the number of pairs in the parentheses. Output Format: For each test case print list of strings denoting all possible combinatio...read more
asked in
System Engineer InterviewView Answers (2)
Q12. Trie Implementation Implement a Trie Data Structure which supports the following two operations: Operation 1 - insert(word) - To insert a string WORD in the Trie. Operation 2- search(word) - To check if a string WORD is present in Trie or not. Trie is a data structure that is like a tree data structure in its organisation. It consists of nodes that store letters or alphabets of words, which can be added, retrieved, and deleted from the trie in a very efficient way. In other words, Trie is an information retrieval data structure, which can beat naive data structures like Hashmap, Tree, etc in the time complexities of its operations. The above figure is the representation of a Trie. New words that are added are inser...read more
asked in
System Engineer InterviewView Answers (2)
Q13. What is your strong point in terms of technical knowledge? Like JAVA, C, C++. What is inheritance? What are the different types of inheritance? What are any two the differences between C++ and Java? How modularity is present in C++? How abstraction and encapsulation complementary? What is a linked list? Differentiate between Arrays and Linked List. What is the difference between array and pointer? Some discussion about my hobbies. Which one is your favorite & why? What does it teach you? Why are you not pursuing dance or basketball as your career? (I mentioned dance & basketball as my hobbies). Tell me one real time situation where you have emerged as a Leader?...read more
asked in
Business Analyst InterviewView Answers (8)
Q14. Merge Sort Linked List You are given a Singly Linked List of integers. Sort the Linked List using merge sort. Merge Sort is a Divide and Conquer algorithm. It divides the input into two halves, calls itself for the two halves, and then merges the two sorted halves. The merge() function is used for merging two halves. The merge(arr, L, M, R) is a key process that assumes that arr[L..M] and arr[M + 1...R] are sorted and merges the two sorted subarrays into one. Input Format: The first line of input contains a single integer T, representing the number of test cases or queries to be run. Then the T test cases follow. The first line of each test case contains the elements of the singly linked list separated by a single s...read more
asked in
System Engineer InterviewView Answers (2)
Q15. Compress the String Ninja has been given a program to do basic string compression. For a character that is consecutively repeated more than once, he needs to replace the consecutive duplicate occurrences with the count of repetitions. Example: If a string has 'x' repeated 5 times, replace this "xxxxx" with "x5". The string is compressed only when the repeated character count is more than 1. Note : The consecutive count of every character in the input string is less than or equal to 9. Input Format: The first line contains an integer 'T' which denotes the number of test cases or queries to be run. The first line of each test case contains one string ‘S’ denoting the input string that needs to be compressed. Output...read more
asked in
System Engineer InterviewView Answers (2)
Q16. Ninja And Divisible Array Ninja has been given an array/list ‘ARR’ of even size ‘N’ and an integer ‘K’. Ninja gives his friend a task to divide the given ‘ARR’ into ‘N’/2 pairs such that the sum of each pair should be divisible by ‘K’. Can you help Ninja to do this task? For Example : If ‘ARR’ = [4 5 6 5 7 3] and ‘K’ = 5 Pairs are(4, 6), (5, 5) ,and (7, 3) and the sum of elements of each pair is divisible by ‘K’ i.e 5. Input Format : The first line contains a single integer ‘T’ representing the number of test cases. The first line of each test case will contain two single space-separated integers ‘N’ and ‘K’ which represent the size of ‘ARR’ and an integer from which the sum of each pair can be divisible. The next ...read more
asked in
System Engineer InterviewView Answers (2)
Q17. Split the String You are given a string ‘str’ of ‘N’ lowercase alphabets. Your task is to check whether it is possible to split the given string into three non-empty substrings such that one of them is a substring of another two. For example: ‘str’ = 'abcabab', we can split this string into 3 string a, b, c as a = 'abc', b = 'ab', c = 'abc', we can clearly see that b is a substring of both a and c. Note: A substring is a contiguous sequence of characters within a string. For example 'ab', 'b' and 'abc' are the substring of string 'abc', but 'ac' is not a substring of 'abc'. A non-empty substring means a substring with a size greater than 0. Input Format: The first line of input contains an integer 'T' representing...read more
asked in
Software Engineer InterviewView Answers (4)
Q18. Group Anagrams You have been given an array/list of strings 'inputStr'. You are supposed to return the strings as groups of anagrams such that strings belonging to a particular group are anagrams of one another. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase. We can generalize this in string processing by saying that an anagram of a string is another string with the same quantity of each character in it, in any order. Note: The order in which the groups and members of the groups are printed does not matter. For example: inputStr = {"eat","tea","tan","ate","nat","bat"} Here {“tea”, “ate”,” eat”} and {“nat”, “tan”} are grouped as anagrams. Since there is no such string ...read more
asked in
System Engineer InterviewView Answers (2)
Q19. Glowing Bulbs There are an infinite number of electric bulbs. Each bulb is assigned a unique integer starting from 1. There are ‘N’ switches also and each switch is labeled by a unique prime number. If a switch labeled with prime integer ‘p’ is turned ON, then all the bulbs having a number that is multiple of ‘p’ will start glowing. For example, if we turn ON the switch labelled 2, then all the bulbs having numbers 2, 4, 6, 8, 10, ... i.e all bulbs with numbers as multiples of 2 will start glowing. You are given an array/list ‘LABELS’ consisting of ‘N’ unique prime integers representing the label of the switches and an integer ‘K’. Your task is to find the integer assigned to Kth glowing bulb from the start when all...read more
asked in
System Engineer Specialist InterviewView Answers (2)
Q20. Number of Islands You have been given a non-empty grid consisting of only 0s and 1s. You have to find the number of islands in the given grid. An island is a group of 1s (representing land) connected horizontally, vertically or diagonally. You can assume that all four edges of the grid are surrounded by 0s (representing water). Input Format: The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows. The first input line of each test case contains two single space-integers ‘N’ and ‘M’ representing the number of rows and columns of the grid, respectively. From the second line of each test case, the next N lines represent the rows of the grid. Every row contains M single spac...read more
asked in
System Engineer InterviewView Answers (3)
1
2
3
4
5
6
7
More about working at Infosys
#19 Best Mega Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Process at null
based on 2.2k interviews in the last 1 year
Interview experience
Very Good
View more
Top HR Questions asked in null
Top Interview Questions from Similar Companies
733 Interview Questions
413 Interview Questions
340 Interview Questions
215 Interview Questions
189 Interview Questions
186 Interview Questions
Share Interview Advice
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 Lakh+
Reviews
4 Lakh+
Interviews
4 Crore+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app