To view the original problem statement, pls check out the source image below đŚ
Imagine you're navigating through a file system that has several storage compartments, each with a unique nameâlet's call them "buckets." You can move between these buckets and create files within them. Your task is to follow a series of commands and, at the end of the day, determine which bucket ended up holding the most files.
Here is how the story unfolds:
Your mission is to process all these commands one by one. At the end of all the instructions, your goal is to figure out which bucket contains the most files. Youâre guaranteed that there wonât be any ties, so there will always be a clear winner.
Here are some things to keep in mind:
Your final task is to identify the bucket that ended up with the most files after all the commands have been processed, and thatâs the bucket youâll declare as the winner!
Example 1:
Input: commands = ["goto bucketA", "create fileA", "create fileB", "create fileA", "goto bucketB", "goto bucketC", "create fileA", "create fileB", "create fileC"]
Output: "bucketC"
Explanation:This explanation is just an educated guess. If you find anything wrong, pls dont hesitate to lmk! Many thanks in advance! 𧥠For the given commands, the number of files in each bucket is as follows:bucketA: 2 files (fileA and fileB) bucketB: 0 files bucketC: 3 files (fileA, fileB, and fileC) Since bucketC has the largest number of files, the output is"bucketC"
.
đŚ
đ


input:
output: