Write a function “runCustomerSimulation” that takes two inputs – an integer: total number of computers in a cafe and a string: a sequence of uppercase letters. Letters in the sequence occur in pairs. The first occurrence indicates the arrival of a customer; the second indicates the departure of that same customer. A customer will be serviced if there is an unoccupied computer. No letter will occur more than two times.
Customers who leave without using a computer always depart before customers who are currently using the computers. There are at most 20 computers per cafe.
For each set of input the function should output a number telling how many customers, if any walked away without using a computer. Return 0 if all the customers were able to use a computer.
runCustomerSimulation (2, “ABBAJJKZKZ”) should return 0
runCustomerSimulation (3, “GACCBDDBAGEE”) should return 1
runCustomerSimulation (3, “GACCBGDDBAEE”) should return 0
runCustomerSimulation (1, “ABCBCA”) should return 2
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
- Fiberlink (maas360) Interview Experience | Set 5 (Online Coding Question)
- Fiberlink (maas360) Interview | Set 1
- Fiberlink (maas360) Interview | Set 3
- Fiberlink (maas360) Interview Experience | Set 4 (Off-Campus)
- Fiberlink Recruitent Process
- Citrix Interview | Set 2 (Written Test Experience)
- National Instruments Interview Experience | Set 1 (Written Test)
- Paytm Interview Experience | Set 7 (Written Test Hyderabad)
- Barclays Interview Experience | Set 1 (On-Campus Written Test for Software Engg)
- MAQ Software Interview Experience | Set 12 (Written Test)
- Amazon Interview Experience | Set 256 (Written Test for SDE1)
- Ittiam Written Test Questions
- Amazon Written Test May 2019 Software Development Engineer I
- Drishti-Soft Solutions Interview | Set 2 (On-Campus Written)
- Amazon interview Experience | Set 137 (Assessment test for SDE)
- National Instruments Interview Experience | Set 3 (Programming Test)
- MAQ Software Interview Experience | Set 11 (On-Campus Writen Test)
- Tesco Bengaluru Interview Experience | Set 1 (Online Coding Test)
- Microsoft Interview Experience | Set 141 (Off-Campus - Online Coding Test for IDC)
- Tesco Interview Experience | Set 2 (Online Test)