Question: Uber OA | IIT Dhanbad | 2023
3
Entering edit mode

Question 1

There are n doors and each door has either rabbit or tortoise.There are x rabbit and y tortoise (x*y = n) If is known that
no two rabbits are together te any two adjacent gates will not have rabbits

Find the minimum number of gates to be open to find the
position of all the rabbits Suppose x = 1 and y = 3,

We open the first gate, the tortoise is present there. So still the position of the rabbit is unknown.
Then if someone opens the third gate, the tortoise is there Still the position of rabbit is unknown. Now if we open any gate, if the tortoise is present then we
know for sure the rabbit will be present in the last one Hence output to this will be 3. It is given that input x and y will be given in such a way that


valid combination is always possible
•[execution time limit] 0.5 seconds (cpp)
• (memory limit) 1 GB
• (input) integer x

 

It is given that input x and y will be given in such a way
tha
valid combination is always possible
• [execution time limit] 0.5 seconds (cpp)


• [memory limit 1 GB


• [input] integer x
Number of rabbits, 0 <=x <= 10^9


•[input] integer y
Number of tortoises, 0<=y<=10^9
The number of gates is exactly number to x+y


• [output] integer
Minimum number of gates to be open to find the
position of all rabbit
[C++] Syntax



Question 2

There is a special lock with a circular dial. A string has been placed around the circular dial in a clockwise manner. There is aiso a passcode
provided to you as a atring. You need to openthe lock with the passcode provided For each of the character in passcode starting
from the first, you have to align the similar character in the circular dial in "12:00* direction. You can rotate the dial by one place in either of
the direction which will be counted as one step. After a character is aligned you will have to
mandatorily press the lock, which is counted as another one step. Find the minimum number of steps to open the lock.

Sample TestCase:
Input: dial = 'HELLOW, passcode = "HO*
Output: 4


Explanation:


For the first passcode character 'H', since it is already in place, we just need 1 step (for pressi
the lock) to this character.
For the second passcode character 'O', we need rotate the dial "HELLOW" clockwise by two steps make it become "OWHELL*
Aiso, we need 1 more step for pressing the lock. So the final output is 4.


Constraint:


1 «= dial length, passcode length  passcode length < 100
dial and passcode consist of only lower case English letters it is guaranteed that passcode could always be set limit 0.5 seconds (cpp)

 



Question 3

You are attending a wedding. And you are excited about lot of festivities that are taking place there Festivity I starts at beginDay and ends at endDay!


represented as festivities[i) = [beginDayi, endDay)


You can only attend one festivity on a day


You can attend a festivity i at any day x where
beginDayi <= x <= endDayi
You want to attend maximum number of festivities What's that number?


• [execution time limit] 0.5 seconds (cp)
•[memory limit] 1 GB
•[input] array.array.integer festivities


List of festivities. Number of festivities can be
at max 10^5. Begin and end days will be <=10^5 where start day <= end day.
. [output] integer
Max festivities you can attend

 

 

ADD COMMENTlink 17 months ago Delta 2.9k

Login before adding your answer.

Similar Posts
Loading Similar Posts