Open In App

Tesco Bengaluru Interview Experience | Set 1 (Online Coding Test)

Last Updated : 15 Oct, 2016
Improve
Improve
Like Article
Like
Save
Share
Report

This is an online coding test conducted by Tesco, Bengaluru.

2 questions – 2 hrs

Question 1
——————-
There are N farms in a row, at each farm you either i) collect apples or ii) drink milk(energy). Visiting each farm costs you one unit of energy. This means if energy becomes zero, you cannot visit anymore farms. Given initial energy (even before first farm is visited) as P, find the maximum number of apples which we can collect.

Input
T (the number of test cases)
N P (in each test case the first line has N-the number of farms and P-the initial energy)
m1 m2 m3 m4 … mN (the milk values at each farm)
a1 a2 a3 … aN (the apples available at each farm)
.
.
.
(t such cases)

Output
In each line, output the maximum number of apples which can be collected.

amax1
amax2
.
.
(t such lines)

Test case 0
2
5 1
5 4 3 2 1
5 4 3 2 1
5 1
3 0 0 1 2
4 5 1 10 20

Expected output for Test case 0
10
6

Question 2
——————-
‘samu’ and ‘vibhu’ are playing a game where there are N integers from 1 to N lying on the table.
In each turn, the player gets to pick one integer to mark as visited from among the previously unvisited ones.
If in a turn, the player picks a number which completes the picking of three consecutive numbers, he wins.
i.e., say at some stage in the game 2 and 4 are already picked(visited) if the player now picks 3, he wins.
Assuming samu starts first and both the players play perfectly optimally, who is the winner.

Input
—————-
T (the number of test cases)
N1 (each case contains just one line with N- the number of integers)
N2
.
.
.
(t such lines)

Output
————-
‘Samu’
‘Vibhu’
.
.
.
(t such lines with just the name of the winner)

Hope this helps.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads