CISCO | OA | August 2022 | Fresher

CISCO | OA| Fresher |SDE|August 2022
Coding Question
Q1. Mail Rooms for Office Buildings
Problem::
Company ABC has corporate campus with multiple buildings. These buildings may or may not be Connected to one other.

Goal::
Please help Alisa determine the least number of mail rooms to be setup so that all buildings are serviced with the following considerations.

Constraints::

  1. A building can host only 1 mall room
  2. A building having a mail room will also service buildings directly connected to it. Hence those directly connected buildings may not host a mail room unless required otherwise.
  3. A building may or may not be connected to other buildings. In such a case, it would
    need its own mail room.
  4. The number of each building X is a random integer where 0<=X<= 10^4
  5. Total number of buildings is P where 0<= P<=10^4
    6.Number of connections is N such that 0<=N<=1000

Q2. Travel Booking Penalties
Sherlock Airlines have come up with a novel way to handle group of travelers who do not plan ahead and end up trying to book similar seat numbers at the travel desk. In the process, they waste everyone's time since only one person can sit at a seat.
Assume all seats are arranged in a straight line & members of the group line up in a queue with their preferred seat number.
Agents of Sherlock Airlines allocate seats with this logic

  1. If seat number is free, the customer at the head of the line gets the seat. Then, the
    customer exits the queue.
  2. If seat is not free, the customer goes back to the end of the line and his preferred seat
    Is bumped up by 1. Also the customer incurs a penalty for the delay caused,
  3. Every time a customer goes back to the end of the line due to a conflict, the penalty doubles and accumulates. I.e if customer A has to go back his/her 1st time, he/she carries a penalty of Rs. 10. If the next time the customer gets to the front of the line and again has a conflict, the penalty doubles. So new penalty is Rs. 20 ( 2nd time) and total penalty is Rs.30. The next penalty would be Rs.40 and total penalty paid by this customer would be Rs. 70.

Constraints:

  1. Total customers say N where 0 <N<=10000
  2. seats are assigned in increasing order,no need to fill prior gaps.

Output:
Return the total number of times customers of the group have been re-queued.

Comments (0)