Atlassian software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question The input is a list of tennis court bookings, where each booking includes a start and end time. You need to write a program that assigns...
Input: Listnull if none exists. If several pages have the highest score, return the page whose most recent score-changing operation occurred latest. Both increases and decreases count as score-changing operations, including operations that move a page into a tie. Calls execute sequentially, so operation order defines recency without timestamps. Queries and no-op decreases do not change recency. A removed page can later be created again.All three operations must run in expected O(1) time, using O(n) space, where n is the number of currently tracked pages. Do not retain historical records for removed pages or empty score groups.Function or class signaturePopularityTracker() — construct an empty tracker.increasePopularity(pageId: str) -> NonedecreasePopularity(pageId: str) -> NonemostPopular() -> str | None{
"operations": [
["increasePopularity", "ENG-101"],
["increasePopularity", "ENG-202"],
["mostPopular"],
["increasePopularity", "ENG-101"],
["mostPopular"],
["increasePopularity", "ENG-202"],
["mostPopular"],
["decreasePopularity", "ENG-202"],
["mostPopular"]
]
}Output, containing results only for mostPopular calls:["ENG-202", "ENG-101", "ENG-202", "ENG-101"]Explanation: The first query sees both scores at one, and
ENG-202 was updated later. Next, ENG-101 alone has score two. Increasing ENG-202 creates a tie at two that it wins by recency. Decreasing it to one leaves ENG-101 as the unique maximum.Example 2:Input:{
"operations": [
["mostPopular"],
["decreasePopularity", "UNKNOWN"],
["increasePopularity", "RUNBOOK"],
["increasePopularity", "RUNBOOK"],
["increasePopularity", "HANDBOOK"],
["decreasePopularity", "RUNBOOK"],
["mostPopular"],
["decreasePopularity", "RUNBOOK"],
["mostPopular"],
["decreasePopularity", "HANDBOOK"],
["mostPopular"],
["increasePopularity", "RUNBOOK"],
["mostPopular"]
]
}Output:[null, "RUNBOOK", "HANDBOOK", null, "RUNBOOK"]Explanation: The tracker starts empty, and decreasing
UNKNOWN changes nothing. Decreasing RUNBOOK from two to one makes it the most recently updated page in the tie with HANDBOOK. Removing RUNBOOK leaves HANDBOOK; removing HANDBOOK empties the tracker. Creating RUNBOOK again gives it score one.Constraints:200000 method calls are made.pageId is a case-sensitive string of 1 to 64 ASCII letters, digits, hyphens, or underscores.1 and 200000 for tracked pages.topK(k: int) -> list[str], ordered by descending score and then descending update recency. Can you return the result in O(min(k, n)) time without changing the expected O(1) update bounds?null when no page has a positive score. Updates must take O(log n) time and this lookup must take O(1), where n is the number of positively scored pages.ConfluencePopularityTracker() — create an empty tracker.increasePopularity(pageId: str) -> int — add one and return the resulting score.decreasePopularity(pageId: str) -> int — subtract one, clamp at zero, and return the resulting score.adjustPopularity(pageId: str, delta: int) -> int — apply a signed adjustment and return the resulting score; adjusting an unknown page by zero or a negative amount leaves it inactive.getMostPopular() -> str | None — return the highest-ranked active page, or null.markViewed(userId: str, pageId: str) -> None — record that the user has viewed the page.getRecommendations(userId: str, k: int) -> list[str] — return at most k unseen page IDs in ranking order; an unknown user has no viewed pages, and k = 0 returns an empty list.[ ["adjustPopularity", "architecture", 5], ["adjustPopularity", "runbook", 5], ["increasePopularity", "onboarding"], ["getMostPopular"], ["markViewed", "alice", "architecture"], ["getRecommendations", "alice", 2], ["decreasePopularity", "architecture"], ["getMostPopular"] ]
[5, 5, 1, "architecture", null, ["runbook", "onboarding"], 4, "runbook"]
[ ["markViewed", "bob", "runbook"], ["adjustPopularity", "runbook", 3], ["adjustPopularity", "runbook", -10], ["getMostPopular"], ["increasePopularity", "runbook"], ["increasePopularity", "architecture"], ["getRecommendations", "bob", 5], ["getRecommendations", "carol", 5], ["getRecommendations", "bob", 0] ]
[null, 3, 0, null, 1, 1, ["architecture"], ["architecture", "runbook"], []]
Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free