Opening your workspace…
Workspace/Coding room
Opening your workspace…
The ticket counter is packed, and each traveler has a destination. Given the destinations in the order travelers reach your window, return the most frequent destination so you can call out the right ticket. If destinations tie, return the one that appeared first.
["Shinjuku","Shibuya","Shinjuku","Tokyo Station"]Output"Shinjuku"Shinjuku is requested twice; every other destination is requested once.
["Ueno","Asakusa","Asakusa","Ueno"]Output"Ueno"Ueno and Asakusa are tied at two requests each, so return the one that appeared first.
Count the destinations, then look for the maximum in arrival order.
function solve(destinations) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.