Infosys SP / DSE coding round, 22 Nov 2026 (KLU Bachupally, Hyderabad, morning)

The four problems reported from the morning shift at KLU Bachupally. The candidate only half remembered the last one, so it is our version of it.

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

Problem 1: Cut the strips (Medium, 25 marks)

You have N strips with the given lengths. You may make at most K cuts in total, each cut splitting one strip into two. Find the largest number of pieces of length exactly L you can end up with.

Input: First line: N K L. Second line: N strip lengths.

Output: The largest number of pieces of length L.

Constraints: 1 ≤ N ≤ 10^5; 0 ≤ K ≤ 10^9; 1 ≤ L, lengths ≤ 10^9.

Input:
3 3 4
8 4 6

Output:
4

More examples and a hint

Problem 2: Pick cards from both ends (Medium, 25 marks)

Cards with values lie in a row. Take exactly K cards, each time from the left end or the right end, with at most R cards taken from the right. Find the largest possible sum of the cards you take.

Input: First line: N K R. Second line: N card values.

Output: The largest sum.

Constraints: 1 ≤ K ≤ N ≤ 10^5; 0 ≤ R ≤ K; −10^4 ≤ values ≤ 10^4.

Input:
6 3 1
1 2 3 4 5 6

Output:
9

More examples and a hint

Problem 3: Cycling the segments with gears (Hard, 25 marks)

A route has N segments; segment i has a slope and a length. Your bike has gears 1 to G. Riding a segment in gear g costs |slope − g| × length. Between segments you may change gear from g to h for s × |g − h|. The starting gear is free. Find the minimum total cost.

Input: First line: N G s. Next N lines: slope and length.

Output: The minimum total cost.

Constraints: 1 ≤ N, G ≤ 2000; 0 ≤ slope, length, s ≤ 10^4.

Input:
3 5 2
1 10
5 6
2 3

Output:
14

More examples and a hint

Problem 4: Stepping down the pond stones (Medium, 25 marks)

An N × N grid of stones: stone (r, c) has a height and a colour. You start on any stone in the top row and want to reach any stone in the bottom row. In one jump you move to a neighbouring stone (up, down, left or right) that is strictly lower and of a different colour. Print the fewest jumps needed, or -1 if the bottom row cannot be reached.

Input: First line: N. Next N lines: the heights. Next N lines: the colours.

Output: The fewest jumps, or -1.

Constraints: 1 ≤ N ≤ 500; heights and colours are integers up to 10^9.

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

Output:
2

More examples and a hint

Infosys test pattern and mock tests · All coding practice