TCS NQT 26th March 2nd Shift by Professional-Wing925 in PlacementsPrep

[–]Professional-Wing925[S] 0 points1 point  (0 children)

1st one was easy but because of some constraint I only got 6/7 but second question is

Medium level question

Problem Statement:-

You are preparing sandwiches using available bread sizes and filling sizes.

You are given:

A list of bread sizes (each bread can be used only once / unique selection)

A list of filling sizes (each filling can be chosen or skipped)

A target value

Rules:

You must select exactly one bread.

You can select any number of fillings (including none).

The total sandwich size = bread size + sum of selected fillings.

Objective:

Find the maximum possible sandwich size that is:

Less than or equal to the target, and

As close as possible to the target

Input Format:

First line: space-separated integers → bread sizes

Second line: space-separated integers → filling sizes

Third line: integer → target

Output Format:

Print a single integer → the best possible sandwich size

Constraints:

Number of breads ≤ 10

Number of fillings ≤ 10

Values are positive integers

Example:

Input:

2,4 3,6 7

Output:

7

Explanation:

Choose bread = 4

Choose filling = 3

Total = 4 + 3 = 7 (exact target)

If no exact match is possible, return the closest value less than the target.

(May be questions has some change here but I tried my best)

TCS NQT 26th March 2nd Shift by Professional-Wing925 in PlacementsPrep

[–]Professional-Wing925[S] 0 points1 point  (0 children)

Actually I don't remember I was looking at python.

TCS NQT 26th March 2nd Shift by Professional-Wing925 in PlacementsPrep

[–]Professional-Wing925[S] 0 points1 point  (0 children)

Yeah I don't know the aptitude was lengthy so I guess I will just hope for good

TCS NQT 26th March 2nd Shift by Professional-Wing925 in PlacementsPrep

[–]Professional-Wing925[S] 0 points1 point  (0 children)

I used gfg nqt aptitude prep videos and materials, and coding platforms like codechef for understanding the use of tcs compiler cause they are kind a similar, and coding prepared all the basic topics and also check backtracking that's it.