02. Shopping List Mid Exam - ПОМОЩ!!!
Здравейте колеги
Judge ми дава 50/100 и не виждам къде е проблема Моля за съдействие.
https://pastebin.com/AdEBxjG4
Input
You will receive an initial list with groceries separated by "!".
After that you will be receiving 4 types of commands, until you receive "Go Shopping!"
- Urgent {item} - add the item at the start of the list. If the item already exists, skip this command.
- Unnecessary {item} - remove the item with the given name, only if it exists in the list. Otherwise skip this command.
- Correct {oldItem} {newItem} – if the item with the given old name exists, change its name with the new one. If it doesn't exist, skip this command.
- Rearrange {item} - if the grocery exists in the list, remove it from its current position and add it at the end of the list.
Constraints
- There won`t be any duplicate items in the initial list
Output
Print the list with all the groceries, joined by ", ".
- "{firstGrocery}, {secondGrocery}, …{nthGrocery}"
Examples
Input |
Output |
Tomatoes!Potatoes!Bread Unnecessary Milk Urgent Tomatoes Go Shopping! |
Tomatoes, Potatoes, Bread |
Input |
Output |
Milk!Pepper!Salt!Water!Banana Urgent Salt Unnecessary Grapes Correct Pepper Onion Rearrange Grapes Correct Tomatoes Potatoes Go Shopping! |
Milk, Onion, Salt, Water, Banana |