Infosys SP / DSE coding round, 29 Nov 2026 (shift 1)

The four problems one candidate reported from the in-person round. They were remembered roughly, so each statement fixes the unclear rules in one clear way.

4 problems, 3 hours, marks 25 / 25 / 25 / 25.

Problem 1: Clothes on a rope (Easy, 25 marks)

A rope is L units long and you have N clothes; cloth i is A[i] units wide. Clothes hang side by side, and each cloth needs a clip at both ends, but two neighbouring clothes share the clip between them, so K clothes need K + 1 clips. Every clip also takes 1 unit of rope. What is the largest number of clothes you can hang?

Input: First line: N and L. Second line: N widths.

Output: The largest number of clothes that fit.

Constraints: 1 ≤ N ≤ 10^5; 1 ≤ L, A[i] ≤ 10^9.

Input:
5 10
2 3 5 4 6

Output:
2

More examples and a hint

Problem 2: Hallway tiling (Medium, 25 marks)

A hallway is L metres long. You cover it, end to end, with tiles 1 metre and 3 metres long. Every 3-metre tile must have a 1-metre tile right next to it (just before it or just after it). Count the different tile sequences, modulo 10^9 + 7. For L = 5 there are 4: [1, 1, 1, 1, 1], [1, 1, 3], [1, 3, 1] and [3, 1, 1].

Input: One line: L.

Output: The number of valid tile sequences modulo 10^9 + 7.

Constraints: 1 ≤ L ≤ 10^6.

Input:
4

Output:
3

More examples and a hint

Problem 3: Birdsong recordings (Hard, 25 marks)

A bird sings the notes of a string S, one note after another. You record exactly M of the notes, keeping their order. Between two recorded notes you may skip at most G notes, and two recorded notes in a row must be different letters. Count the ways to choose which M notes to record, modulo 10^9 + 7.

Input: First line: S. Second line: M. Third line: G.

Output: The number of ways modulo 10^9 + 7.

Constraints: 1 ≤ M ≤ |S| ≤ 2000; 0 ≤ G ≤ |S|; S has lowercase letters.

Input:
abca
3
1

Output:
4

More examples and a hint

Problem 4: Minimum cost paper folding (Hard, 25 marks)

A strip of paper has N squares in a row; square i weighs W[i]. You fold it along a line between two squares: the shorter side is lifted and laid over the longer side (if both sides are equal, the left side is lifted). A fold costs the total weight of the lifted side, and each square of the longer side then carries the weight that landed on it. Keep folding until the paper is a single stack one square wide. Print the minimum total cost.

Input: First line: N. Second line: N weights.

Output: The minimum total folding cost.

Constraints: 1 ≤ N ≤ 14; 1 ≤ W[i] ≤ 1000.

Input:
2
3 5

Output:
3

More examples and a hint

Infosys test pattern and mock tests · All coding practice