Infosys SP OA
- Posted
- 10 Feb 2026
Summary
I participated in an Online Assessment for Infosys, which included four distinct coding questions covering a range of difficulties from easy to hard, focusing on array manipulation, score maximization, number theory conditions, and complex graph traversal with adjacency matrix shifts.
How it went
4 questions:
- Easy : given array with n elements merge adjacent elements in any order if the sum is less than k, return length of array after performing all valid merges.
- Medium : Given array maximise score, note returned score should be even.
- score : sum of selected elements.
- if u choose an element at index i then u have to move to i + (arr[i] % 2) index
- Hard : Given n, m, g, l Return the number of arrays of size n that can be formed with integers from 1 to m such that
- for odd index i gcd(arr[i], arr[i+1]) > g
- for even index i lcm(arr[i], arr[i+1]) < l
- Complex: Given graph of n nodes with adjaceny list
- Find all the paths from node 1 to n whose path length is K
- For every move from one node to another the adjaceny matrix makes a right cyclical shift on its rows
Questions asked (4)
- 01
Merge Adjacent Elements with Sum Threshold
Data Structures & Algorithms · Easy
Given an array with n elements, merge adjacent elements in any order if their sum is less than k. Return the length of the array after performing all valid merges.
- 02
Maximize Even Score with Index Jumps
Data Structures & Algorithms · Medium
Given an array, maximize the score such that the returned score is even. The score is the sum of selected elements. If you choose an element at index i, you have to move to index i + (arr[i] % 2).
- 03
Count Arrays with GCD/LCM Conditions
Data Structures & Algorithms · Hard
Given n, m, g, l. Return the number of arrays of size n that can be formed with integers from 1 to m such that:
- For odd index i, gcd(arr[i], arr[i+1]) > g
- For even index i, lcm(arr[i], arr[i+1]) < l
- 04
Paths of Length K with Shifting Adjacency Matrix
Data Structures & Algorithms
Given a graph of n nodes with an adjacency list:
- Find all the paths from node 1 to n whose path length is K.
- For every move from one node to another, the adjacency matrix makes a right cyclical shift on its rows.