Problem database last updated: June 20, 2025

IInfosys logo

Infosys Coding Interview Questions

99 problems · 31 Easy, 53 Medium, 15 Hard · Ranked #14 of 458

Difficulty breakdown

31 Easy

31% · avg 23%

53 Medium

54% · avg 59%

15 Hard

15% · avg 18%

Top topics

array
60.6%
string
24.2%
math
22.2%1.8x
dynamic-programming
21.2%
sorting
17.2%
two-pointers
17.2%

Interview profile

Based on 99 reported problems, Infosys interviews are in line with industry averages - 15% Hard vs 18% overall. The majority (54%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, Infosys puts unusual emphasis on number-theory (2% of problems, 3.9x the industry average), combinatorics (2% of problems, 3.6x the industry average), segment-tree (2% of problems, 3.3x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (60.6%), string (24.2%), math (22.2%), dynamic-programming (21.2%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 99 problems

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyVery Likely
arrayhash-map

Find Building Where Alice and Bob Can Meet

Solve

You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.

HardVery Likely
arraybinary-searchstack

Minimum Reverse Operations

Solve

You are given an integer n and an integer p representing an array arr of length n where all elements are set to 0's, except position p which is set to 1. You ar...

HardVery Likely
arrayhash-tablebreadth-first-search

Count the Number of Ideal Arrays

Solve

You are given two integers n and maxValue, which are used to describe an ideal array.

HardVery Likely
mathdynamic-programmingcombinatorics

Transform Array By Parity

Solve

You are given an integer array nums. Transform nums by performing the following operations in the exact order specified: Replace each even number with 0, replac...

EasyVery Likely
arraycountingsorting

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumVery Likely
hash-tablestringsliding-window

Eat Pizzas

Solve

You are given an integer array pizzas of size n, where pizzas[i] represents the weight of the ith pizza. Every day, you eat exactly 4 pizzas. When you eat pizza...

MediumVery Likely
greedyarraysorting

Maximum Sum of Subsequence With Non-adjacent Elements

Solve

You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi].

HardVery Likely
arraydivide-and-conquerdynamic-programming

Stone Game VIII

Solve

Alice and Bob take turns playing a game, with Alice starting first.

HardVery Likely
arraymathdynamic-programming

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyVery Likely
arraydynamic-programming

The Number of Beautiful Subsets

Solve

You are given an array nums of positive integers and a positive integer k.

MediumVery Likely
arrayhash-tablemath

Can Convert String in K Moves

Solve

Given two strings s and t, your goal is to convert s into t in k moves or less.

MediumVery Likely
hash-tablestring

Number of Beautiful Integers in the Range

Solve

You are given positive integers low, high, and k.

HardVery Likely
mathdynamic-programming

Sort the People

Solve

You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.

EasyVery Likely
arrayhash-tablestring

Determine the Minimum Sum of a k-avoiding Array

Solve

You are given two integers, n and k.

MediumVery Likely
mathgreedy

Maximize The Minimum Game Score

Solve

You are given an array points of size n and an integer m. There is another array gameScore of size n, where gameScore[i] represents the score achieved at the it...

HardVery Likely
greedyarraybinary-search

Find the Minimum Possible Sum of a Beautiful Array

Solve

You are given positive integers n and target.

MediumVery Likely
mathgreedy

Maximum Number of Consecutive Values You Can Make

Solve

You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if...

MediumVery Likely
arraygreedysorting

Minimum Addition to Make Integer Beautiful

Solve

You are given two positive integers n and target.

MediumVery Likely
mathgreedy

Minimum Total Distance Traveled

Solve

There are some robots and factories on the X-axis. You are given an integer array robot where robot[i] is the position of the ith robot. You are also given a 2D...

HardVery Likely
arraydynamic-programmingsorting

Maximum Segment Sum After Removals

Solve

You are given two 0-indexed integer arrays nums and removeQueries, both of length n. For the ith query, the element in nums at the index removeQueries[i] is rem...

HardVery Likely
arrayunion-findprefix-sum

Find The Number Of Subsequences With Equal Gcd

Solve

You are given an integer array nums. Your task is to find the number of pairs of non-empty subsequences (seq1, seq2) of nums that satisfy two conditions: the su...

HardVery Likely
arraymathdynamic-programming

Maximum Product After K Increments

Solve

You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.

MediumVery Likely
arraygreedyheap-priority-queue

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyVery Likely
stringstack

Largest Number After Mutating Substring

Solve

You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to anoth...

MediumVery Likely
arraystringgreedy

Longest Well-Performing Interval

Solve

We are given hours, a list of the number of hours worked per day for a given employee.

MediumVery Likely
arrayhash-tablestack

Next Permutation

Solve

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

MediumVery Likely
arraytwo-pointers

Merge Sorted Array

Solve

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num...

EasyVery Likely
arraytwo-pointerssorting

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumVery Likely
arraydivide-and-conquerdynamic-programming

Palindrome Number

Solve

Given an integer x, return true if x is a palindrome, and false otherwise.

EasyVery Likely
math

Remove Duplicates from Sorted Array

Solve

Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order o...

EasyVery Likely
arraytwo-pointers

Reverse String

Solve

Write a function that reverses a string. The input string is given as an array of characters s.

EasyLikely
two-pointersstring

Rotate Image

Solve

You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

MediumLikely
arraymathmatrix

Longest Common Prefix

Solve

Write a function to find the longest common prefix string amongst an array of strings.

EasyLikely
arraystringtrie

Valid Anagram

Solve

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

EasyLikely
hash-tablestringsorting

Product of Array Except Self

Solve

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

MediumLikely
arrayprefix-sum

Second Highest Salary

Solve

Table: Employee

MediumLikely
database

Trapping Rain Water

Solve

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

HardLikely
arraytwo-pointersdynamic-programming

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumLikely
stringdynamic-programmingbacktracking

Coin Change

Solve

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

MediumLikely
arraydynamic-programmingbreadth-first-search

Spiral Matrix

Solve

Given an m x n matrix, return all elements of the matrix in spiral order.

MediumLikely
arraymatrixsimulation

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumLikely
arraysorting

3Sum

Solve

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

MediumLikely
arraytwo-pointerssorting

Rotate Array

Solve

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

MediumLikely
arraymathtwo-pointers

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumLikely
arrayhash-tablestring

Reverse Integer

Solve

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1...

MediumLikely
math

Fibonacci Number

Solve

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, startin...

EasyLikely
mathdynamic-programmingrecursion

Palindrome Partitioning

Solve

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.

MediumLikely
stringdynamic-programmingbacktracking

Merge Two Sorted Lists

Solve

You are given the heads of two sorted linked lists list1 and list2.

EasyLikely
linked-listrecursion

Reverse Nodes in k-Group

Solve

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.

HardLikely
linked-listrecursion

Move Zeroes

Solve

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

EasyLikely
arraytwo-pointers

Number of Islands

Solve

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

MediumLikely
arraydepth-first-searchbreadth-first-search

Longest Consecutive Sequence

Solve

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

MediumLikely
arrayhash-tableunion-find

Single Element in a Sorted Array

Solve

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.

MediumLikely
arraybinary-search

Gas Station

Solve

There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

MediumLikely
arraygreedy

Two Sum II - Input Array Is Sorted

Solve

Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number....

MediumLikely
arraytwo-pointersbinary-search

Sort an Array

Solve

Given an array of integers nums, sort the array in ascending order and return it.

MediumLikely
arraydivide-and-conquersorting

Find the Index of the First Occurrence in a String

Solve

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

EasyLikely
two-pointersstringstring-matching

House Robber

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from rob...

MediumLikely
arraydynamic-programming

Add Two Numbers

Solve

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing...

MediumLikely
linked-listmathrecursion

Reverse Words in a String

Solve

Given an input string s, reverse the order of the words.

MediumLikely
two-pointersstring

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumLikely
two-pointersstringdynamic-programming

Missing Number

Solve

Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

EasyLikely
arrayhash-tablemath

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumLikely
arraydivide-and-conquersorting

Climbing Stairs

Solve

You are climbing a staircase. It takes n steps to reach the top.

EasyLikely
mathdynamic-programmingmemoization

Rearrange Array Elements by Sign

Solve

You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.

MediumLikely
arraytwo-pointerssimulation

Sqrt(x)

Solve

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.

EasyLikely
mathbinary-search

Roman to Integer

Solve

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

EasySometimes
hash-tablemathstring

Median of Two Sorted Arrays

Solve

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

HardSometimes
arraybinary-searchdivide-and-conquer

Maximum Depth of Binary Tree

Solve

Given the root of a binary tree, return its maximum depth.

EasySometimes
treedepth-first-searchbreadth-first-search

Edit Distance

Solve

Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.

MediumSometimes
stringdynamic-programming

Valid Palindrome

Solve

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forwa...

EasySometimes
two-pointersstring

Koko Eating Bananas

Solve

Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.

MediumSometimes
arraybinary-search

Combination Sum II

Solve

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to...

MediumSometimes
arraybacktracking

Pow(x, n)

Solve

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

MediumSometimes
mathrecursion

Subsets

Solve

Given an integer array nums of unique elements, return all possible subsets (the power set).

MediumSometimes
arraybacktrackingbit-manipulation

Container With Most Water

Solve

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

MediumSometimes
arraytwo-pointersgreedy

Maximum Score Words Formed by Letters

Solve

Given a list of words, list of single letters (might be repeating) and score of every character.

HardSometimes
arrayhash-tablestring

Create a DataFrame from List

Solve

Write a solution to create a DataFrame from a 2D list called studentdata. This 2D list contains the IDs and ages of some students.

EasySometimes

Implement Queue using Stacks

Solve

Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, an...

EasySometimes
stackdesignqueue

Jump Game

Solve

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...

MediumSometimes
arraydynamic-programminggreedy

String to Integer (atoi)

Solve

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer.

MediumSometimes
string

Search in Rotated Sorted Array

Solve

There is an integer array nums sorted in ascending order (with distinct values).

MediumSometimes
arraybinary-search

Minimum Window Substring

Solve

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is inc...

HardSometimes
hash-tablestringsliding-window

4Sum

Solve

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

MediumSometimes
arraytwo-pointerssorting

Best Time to Buy and Sell Stock II

Solve

You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

MediumSometimes
arraydynamic-programminggreedy

Combination Sum

Solve

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...

MediumSometimes
arraybacktracking

To Lower Case

Solve

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

EasySometimes
string

Average Time of Process per Machine

Solve

Table: Activity

EasySometimes
database

Find the Duplicate Number

Solve

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

MediumSometimes
arraytwo-pointersbinary-search

Binary Search

Solve

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then ret...

EasySometimes
arraybinary-search

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumSometimes
arrayhash-tableprefix-sum

Kids With the Greatest Number of Candies

Solve

There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer ex...

EasySometimes
array

Car Fleet

Solve

There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.

MediumSometimes
arraystacksorting

Isomorphic Strings

Solve

Given two strings s and t, determine if they are isomorphic.

EasySometimes
hash-tablestring

Greatest Common Divisor of Strings

Solve

For two strings s and t, we say "t divides s" if and only if s = t + t + t + ... + t + t (i.e., t is concatenated with itself one or more times).

EasySometimes
mathstring

Integer to Roman

Solve

Seven different symbols represent Roman numerals with the following values:

MediumSometimes
hash-tablemathstring

Replace Employee ID With The Unique Identifier

Solve

Table: Employees

EasySometimes
database

Maximum Product of Three Numbers

Solve

Given an integer array nums, find three numbers whose product is maximum and return the maximum product.

EasySometimes
arraymathsorting

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent Infosys interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your Infosys coding interview

Infosys interviews focus heavily on array, string, math problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. Infosys interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does Infosys ask in interviews?add

Infosys has been reported to ask 99 distinct coding problems. The most common topics are array, string, math. 31 are Easy difficulty, 53 are Medium, and 15 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are Infosys coding interviews?add

Based on 99 reported problems, Infosys interviews are in line with industry averages - 15% Hard vs 18% overall. 54% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a Infosys coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, math. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your Infosys interview?

Simulate a real Infosys coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a Infosys interview with AIarrow_forward