0% found this document useful (0 votes)
21 views

Uber Interview

Uploaded by

vices61134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Uber Interview

Uploaded by

vices61134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Given a number in base 2, convert it into base 6

For e.g.

1100 in base 2 represented as [false, false, true, true] in test #1,

12 in base 10, and

20 in base 6 represented as [0, 2] in test #1.

[execution time limit] 3 seconds (java)

[input] array.boolean base2

Max length = 100

if ith position of the array is true that means the ith position of the number is 1.

[output] array.integer

ith position of the array represents the ith position of the number is in base 6

2.Task 2 of 3

You are given n problems of varying difficulty as homework. This homework is to be submitted in exactly h days of
the holidays.

The problems are given to you in an order and must be submitted in order. That is, before solving the problem at ind
ex q, all problems at index p, where p < q should be finished.

You must submit atleast 1 problem every day, including on the last day. The teacher is a sadist and does not allow fo
r finishing the homework early.

The difficulty of a day is the difficulty of the most difficult problem solved on that day. The difficulty of the holiday
s is the sum of difficulty of all days.

Optimize the way you solve the problems and return the minimum possible difficulty with which you can spend you
r holidays. If it is not possible to solve the problems in a way that satisfies the constraints, return -1.

1 <= n <= 750 [You may get atmost 750 problems as homework]
0 <= di <= 1000 [The difficulty of each problem is an integer between 0 and 1000 (inclusive) ]
1 <= h <= 30 [The holidays are long and may last upto 30 days (inclusive) ]

Example1:
problems = [3,5,7,2,1,8,3,3,3] h = 4
day1 = 3,5,7,2,1,8 [8]
day2 = 3 [3]
day3 = 3 [3]
day4 = 3 [3]
answer = 8 + 3 + 3 + 3 = 17
This is the minimum difficulty of the holidays

Example2:
problems = [3,1,1,1,8] h = 3
day1 = 3 [3]
day2 = 1,1,1 [1]
day3 = 8 [8]
answer = 3 + 1 + 8 = 12

Example3:
problems = [1,1,1,1] h = 5
The answer is -1 because you cannot submit problems on each day, one day will be free.

Example4:
problems = [1,1,1,2,1,1,9] h = 2
answer = 10

Example5:
problems = [1,2,3,1,2,3,1,2,3] h = 8
answer = 16

[execution time limit] 3 seconds (java)

[input] array.integer problems

The problems given as homework, in order.

[input] integer holidays

The number of days the holidays last.

[output] integer

The minimum difficulty in which you can complete the holidays

3.
Bowling is a sport in which a player rolls a bowling ball towards a group of pins, the target being to knock down the
pins at the end of a lane. In this challenge, the rules of the game are slightly modified. Now, there are n number of pi
ns, n is even, and the pins are arranged in a horizontal line instead of a triangular formation. ith pin has number arr[i]
on it. In each throw you have to knock down exactly two consecutive pins. Once you knock down pins at positions i
and i+1, those present at i-1 and i+2 will become adjacent. And you'll get arr[i-1]*arr[i]*arr[i+1]*arr[i+2] points for
knocking ith and i+1th pins down. If i-1 or i+2 goes out of bounds, assume that there is a pin with number 1 on it at t
hat position.

Find out the maximum number of points one can get when played wisely. Since the answer can be large, return answ
er modulo 1e9 + 7 as output.

Input: An array of length n - numbers on the pins


Output: Single integer

Examples:

Input: arr = [3,1,5,8]


Output: 144
Explaination:
arr = [3, 1, 5, 8] -> [3, 8] -> []
points = 3*1*5*8 + 1*3*8*1 = 144
Input: arr = [1, 5]
Output: 5
Explaination:
arr = [1, 5] -> []
points = 1*1*5*1 = 144

Constraints:

n == arr.length, n is even

1 <= n < 200

0 <= arr[i] <= 100

[execution time limit] 3 seconds (java)

[input] array.integer arr

[output] integer

You might also like