Infosys SP OA
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.
Full Experience
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
Interview Questions (4)
Merge Adjacent Elements with Sum Threshold
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.
Maximize Even Score with Index Jumps
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).
Count Arrays with GCD/LCM Conditions
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
Paths of Length K with Shifting Adjacency Matrix
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.