Problem · Hash Table
Goto Largest Bucket
Learn this problemProblem statement
Process commands in a virtual environment:
goto <bucket_name>changes the current bucket. The bucket is guaranteed to exist.create <filename>creates that file in the current bucket. If the same filename already exists in that bucket, nothing happens.
Return the bucket containing the largest number of distinct files after all commands. The first command is a goto, at least one command is a create, and the largest bucket is unique.
Function
databricksGotoLargestBucket(commands: String[]) → StringExamples
Example 1
commands = ["goto bucketA", "create fileA", "create fileB", "create fileA", "goto bucketB", "goto bucketC", "create fileA", "create fileB", "create fileC"]return = "bucketC"bucketA contains two distinct files, bucketB contains none, and bucketC contains three.
Constraints
🦅🙉More Databricks problems
- Find First Anagram IndexPHONE SCREEN · Seen Apr 2026
- Minimize CommuteOA · Seen Apr 2026
- Difference Between Sums of PositionsSeen Sep 2024
- Longest Common Prefix of Number PairsSeen Sep 2024
- Subarray CountingSeen Sep 2024
- Write 'Y' on MatrixSeen Sep 2024
- Binary String RequestsSeen Aug 2024
- Bouncing Diagonal WeightsSeen Aug 2024