Capacity-Bounded Browser History
Updated
Problem statement
Given operations, urls and capacity, return the URLs left in a browser history after running every operation, from least recently visited to most recently visited.
The history holds at most capacity distinct URLs. Operation operations[i] goes with urls[i].
visit: if the URL is already in the history, remove its old spot. Then add it as the most recent URL. If the history now holds more thancapacityURLs, remove the least recent one.clear: remove every URL. The matching value inurlsis ignored.
Function
finalBoundedHistory(operations: String[], urls: String[], capacity: int) → String[]Examples
Example 1
operations = ["visit","visit","visit","visit"]urls = ["a","b","a","c"]capacity = 2return = ["a","c"]After visiting a, b and a again, a is the most recent URL and b the least recent. Visiting c goes over the capacity, so b is removed, leaving a then c.
Constraints
- Arrays have equal length.
0 <= capacity <= 10^5.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- LRU CacheGimlet Labs · PHONE SCREEN
- LRU CacheBNSF Railway · PHONE SCREENBNSF Railway interview questions
- Max Frequency TrackerProcol · PHONE SCREEN
- Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
- LRU Cache Operation SequenceCARS24 · PHONE SCREEN
- LRU Key-Value Cache OperationsCohesity · PHONE SCREEN
- Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
- LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)