InterviewSolution
Saved Bookmarks
| 1. |
A = 0, B = 0, C = 0 while (Pile 1 has more cards) {Read the top card X from Pile 1A, B, C = DoSomething(X, A, B, C)Move X to Pile 2}Procedure DoSomething(Y, A, B, C) {if (Y.ShopName == “SV Stores” and Y.TotalBillAmount > A) {A = Y.TotalBillAmount}if (Y.ShopName == “Big Bazaar” and Y.TotalBillAmount > B) {B = Y.TotalBillAmount}if (Y.ShopName == “Sun General” and Y.TotalBillAmount > C) {C = Y.TotalBillAmount}return ([A, B, C]) |
|
Answer» ............................... |
|