Company-style OA practice sets with full problem statements, sample test cases, and solutions.
Have you recently taken Infosys's Online Assessment or coding test? Share the questions, test cases, or assessment patterns you encountered. Earn SWE180 Coins for every verified submission and use them to unlock other company OA sets and premium tools for free!
You are given an array pts of N integers representing point positions on a number line. You are also given a window length L and a modulo factor K.
You must select a subset of points from pts that satisfies two conditions:
1. All points in your selected subset must yield the exact same remainder when divided by K.
2. The difference between the absolute maximum position and the absolute minimum position in your selected subset must be less than or equal to L (i.e. max(subset) - min(subset) <= L).
Find the maximum number of points you can include in a valid subset.
Example 1
Input
8 6 3 1 4 7 10 13 2 5 8
Output
3
Explanation
Points with remainder 1 modulo 3: [1, 4, 7, 10, 13].
Subarrays with range <= 6:
- [1, 4, 7]: 7 - 1 = 6 <= 6 (3 points)
- [4, 7, 10]: 10 - 4 = 6 <= 6 (3 points)
- [7, 10, 13]: 13 - 7 = 6 <= 6 (3 points)
Points with remainder 2 modulo 3: [2, 5, 8]: 8 - 2 = 6 <= 6 (3 points).
Maximum valid subset size is 3.
You are given two integers N and K.
You need to count the number of binary strings of length N such that:
- The string does not contain K consecutive 1s.
- The first and last characters of the string are different.
Find the number of valid strings modulo 10^9 + 7.
Example 1
Input
4 2
Output
4
Explanation
Valid strings of length 4 with no 2 consecutive 1s where first and last characters differ:
- '0001'
- '0101'
- '1000'
- '1010'
Total = 4 strings.
Example 2
Input
4 3
Output
6
Explanation
For N = 4 and K = 3 (no '111'):
Starting with '0' and ending with '1': '0001', '0011', '0101' (3 strings).
By symmetry, starting with '1' and ending with '0': '1000', '1100', '1010' (3 strings).
Total = 3 + 3 = 6.
You need to find the length of the longest pair of substrings (one from A and one from B) that have the exact same length and differ in at most 1 position.
Additionally, if the two substrings differ in exactly 1 position, the two mismatched characters must either both be vowels ('a', 'e', 'i', 'o', 'u') or both be consonants. If the mismatched characters do not share the same vowel/consonant type, the mismatch is considered invalid and the substrings do not meet the criteria.
Find the length of the longest valid pair of substrings.
Example 1
Input
cat bat
Output
3
Explanation
'c' and 'b' differ in exactly 1 position, and both are consonants. Substrings 'cat' and 'bat' are valid with length 3.
Example 2
Input
cat cut
Output
3
Explanation
'a' and 'u' differ in exactly 1 position, and both are vowels. Substrings 'cat' and 'cut' are valid with length 3.
Example 3
Input
cat eat
Output
2
Explanation
'c' (consonant) and 'e' (vowel) have different types, making the mismatch invalid. The longest valid matching substring is 'at' with length 2.
Gain complete transparency into the Infosys online assessment process. Prepare effectively with real, verified coding challenges, test patterns, and platform details.
Wondering what top companies are actually asking in their initial screening rounds? We provide exact Data Structures, Algorithms, and logical reasoning questions reported by candidates who recently took the Infosys online tests. Stop guessing and start practicing the right problems.
Understand exactly how many questions to expect, the typical time limits, and the platforms used (e.g., HackerRank, Codility, CodeSignal). Knowing the format in advance is the first step to clearing the Infosys OA.