Question 1: Minimum Cost with Ban and Sponsor Strings
We are given:
-
An integer N representing the number of rows.
-
A cost matrix with N rows and 4 columns, corresponding to the characters a, b, c, and d.
-
Two comma-separated strings: ban and sponsor.
The task is to determine the minimum total cost while following the restrictions involving the banned and sponsored characters.
Example:
N = 2
5 1 1 1
5 1 1 1
ban = ba,cc,dd
sponsor = a
Output: 6
I'm not completely sure about the exact wording of the restrictions, so any help reconstructing this question would be appreciated.
Question 2: Planting Seeds in Pots
We are given two arrays:
A seed can be planted in a pot only if:
pot >= seed and pot < 2 * seed
Each pot can hold at most one seed, and each seed can be planted in at most one pot.
The task is to find the maximum number of seeds that can be planted.
Example:
seeds = [2, 3, 4]
pots = [3, 5, 8]
Output: 2
Question 3: Minimum Cost to Monitor Circular Towers
There are N towers arranged in a circular order.
A guard placed at a tower can monitor:
Therefore, one guard can monitor up to 5 towers.
Each tower is given with a cost and an indicator (0 or 1). We need to find the minimum cost required to ensure that all towers are monitored.
Examples:
Example 1:
N = 5
1 0
1 0
1 0
1 0
1 0
Output: 2
Example 2:
N = 5
1 1
1 0
1 0
1 0
1 0
Output: 1
Example 3:
N = 5
3 1
4 0
4 0
4 0
4 0
Output: 3
I hope this helps anyone preparing for the Infosys OA.
All the best to everyone appearing for the upcoming tests!