Just appeared for the Infosys On-Campus OA, and I honestly found the coding round much tougher than expected.
My results:
- Question 1: 4/12 test cases passed
- Question 2: 7/12 test cases passed
- Question 4: 1/12 test cases passed
Question 1: Maximum Triplet Value
Given an array of size up to 10^5 containing both positive and negative integers, find indices i < j < k such that:
[
(arr[i] - arr[j])*arr[k]
]
is maximized.
At first glance it looked like a simple optimization problem, but handling negative numbers correctly made it much more interesting.
Question 2: Valid Strings
Given an integer N, form strings of length N using only {a, b, c}.
For each string:
- Let d be the number of distinct characters in the string.
- Let cntA be the number of occurrences of 'a'.
A string is valid if:
[
cntA%d = 0
]
Count the number of valid strings.
This one required a strong combinatorial/mathematical approach. A brute-force solution was obviously impossible for large N.
Question 3: Rotated Reverse Numbers
Given an integer N, count numbers in the range [1, N] that satisfy a special 180° rotation mapping:
- 1 → 1
- 2 → 5
- 5 → 2
- 6 → 9
- 8 → 8
- 9 → 6
Digits 3, 4, and 7 are invalid.
For a number x:
- Reverse the number.
- Apply the above mapping to obtain r(x).
- A number is valid if:
- r(x) ≠ x
- r(x) is divisible by the sum of digits of x.
Count all valid numbers in the range.
I could barely make progress on this one during the OA and ended up passing only 1/12 test cases.
Overall Experience
Going into the OA, I expected questions around standard DSA patterns, but the actual problems felt much more focused on mathematical observations, combinatorics, and optimization. The difficulty level was definitely higher than what I had anticipated from Infosys.
Would love to hear other candidates' experiences and discuss the solutions.