Infosys SP / DSE coding round, 22 Nov 2026 (other shifts)

Problems other candidates reported from the same day, put together as one paper.

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

Problem 1: Saplings and pots (Medium, 25 marks)

You have N saplings and M pots with the given widths. A sapling of width r fits a pot of width p when r ≤ p ≤ 2r. Each pot holds at most one sapling. Find the largest number of saplings you can pot.

Input: First line: N M. Second line: N sapling widths. Third line: M pot widths.

Output: The largest number of potted saplings.

Constraints: 1 ≤ N, M ≤ 10^5; 1 ≤ widths ≤ 10^9.

Input:
3 3
2 3 5
4 6 11

Output:
2

More examples and a hint

Problem 2: Café loyalty stickers (Medium, 25 marks)

A café gives a free coffee to every customer with at least R stickers. Customer i has s[i] stickers and may be given at most e[i] bonus stickers. The café has B bonus stickers in total. Find the largest number of customers who can get a free coffee.

Input: First line: N. Next N lines: s[i] and e[i]. Last line: R and B.

Output: The largest number of free coffees.

Constraints: 1 ≤ N ≤ 10^5; 0 ≤ s[i], e[i] ≤ 10^9; 1 ≤ R, B ≤ 10^14.

Input:
4
5 2
3 1
8 0
1 9
6 5

Output:
2

More examples and a hint

Problem 3: Dominoes with separated squares (Hard, 25 marks)

Tile a 2 × N board completely with 1 × 2 dominoes (placed either way) and 1 × 1 squares, so that no two 1 × 1 squares share a side. Count the tilings modulo 10^9 + 7.

Input: One line: N.

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

Constraints: 1 ≤ N ≤ 10^5.

Input:
1

Output:
1

More examples and a hint

Problem 4: Loading two ships (Hard, 25 marks)

N containers with the given weights are loaded one by one, each onto ship A or ship B. Ship A can carry at most CA and ship B at most CB. When everything is loaded, the difference between the two ships' totals must be less than D. Count the ways to load the containers, modulo 10^9 + 7.

Input: First line: N. Second line: N weights. Third line: CA CB D.

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

Constraints: 1 ≤ N ≤ 100; 1 ≤ weights ≤ 1000; 1 ≤ CA, CB ≤ 10^5; 1 ≤ D ≤ 10^5.

Input:
3
1 2 3
4 4 1

Output:
2

More examples and a hint

Infosys test pattern and mock tests · All coding practice