Notion software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for Notion.
ImageCarousel component that displays a list of images and allows users to navigate through them using next and previous buttons. The component should automatically cycle through images every few seconds as well. Implement the following methods:next(): Navigate to the next image.prev(): Navigate to the previous image.display(): Output the currently visible image.class ImageCarousel: def __init__(self, images: List[str]): def next(self) -> None: def prev(self) -> None: def display(self) -> str: Example 1: carousel = ImageCarousel(['image1.jpg', 'image2.jpg', 'image3.jpg']) carousel.display() 'image1.jpg' carousel.next() carousel.display() 'image2.jpg' carousel.prev() carousel.display() 'image1.jpg' . ImageCarousel with the following methods. def __init__(self, images: List[str]): def next_image(self) -> str: def previous_image(self) -> str: def display(self) -> None: carousel = ImageCarousel(['image1.jpg', 'image2.jpg', 'image3.jpg']) carousel.display() → Displays image1.jpg, then carousel.next_image() displays image2.jpg. next_image() method navigates to the second image. carousel.previous_image() image3.jpg again after going back. n, must be greater than 0. class ImageSlider:def __init__(self, images: List[str]) -> None:def next_image(self) -> str:def prev_image(self) -> str:def current_image(self) -> str:slider = ImageSlider(['url1', 'url2', 'url3']) followed by slider.next_image() 'url2' url1, and calling next_image() moves it to url2.slider.prev_image() after the previous example 'url1' url1 since the slider can navigate through its images in a loop.images list will contain at least 1 and at most 100 images.get(key: int) -> int and put(key: int, value: int). The get method returns the value of the key if present, otherwise returns -1. The put method updates the value of the key if the key exists. If the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item. def get(self, key: int) -> int:def put(self, key: int, value: int) -> None:cache = LRUCache(2) cache.put(1, 1) cache.put(2, 2) print(cache.get(1)) # returns 1 cache.put(3, 3) # evicts key 2 print(cache.get(2)) # returns -1 (not found)
1, -1 cache = LRUCache(1) cache.put(1, 1) print(cache.get(1)) # returns 1 cache.put(2, 2) # evicts key 1 print(cache.get(1)) # returns -1 (not found)
1, -1 0 < capacity <= 10000 <= key, value <= 10^42 * 10^5 times.string representing lines of a document. Write a function that identifies if there are any duplicate lines. Return true if there are duplicates, otherwise return false. def has_duplicates(lines: List[str]) -> bool:['Line 1', 'Line 2', 'Line 1'] true ['Hello World', 'Notion Rocks', 'Welcome to Notion'] false s, return the first non-repeating character. If all characters are repeating, return None.def first_non_repeating_character(s: str) -> Optional[str]:None def generateMarkdown(blocks: List[str]) -> List[str]:blocks contains strings representing different block types like 'text', 'image', 'todo'.Example 1:blocks = ['text', 'image']['text', 'image', 'text
image', 'image
text']blocks = ['text', 'todo']['text', 'todo', 'text
todo', 'todo
text']Constraints:1 <= blocks.length <= 10blocks[i] consists of unique types only.def countChanges(changes: List[Tuple[int, int]], window: int) -> int: where changes is a list of tuples representing changes with start and end times.changes = [(1, 4), (2, 5), (5, 7)], window = 33changes = [(1, 2), (2, 6), (5, 10)], window = 531 <= changes.length <= 10^51 <= changes[i][0], changes[i][1] <= 10^9addImage(imageUrl: str, caption: str) -> None - Adds an image with its caption to the carousel. removeImage(imageUrl: str) -> None - Removes an image from the carousel based on its URL. nextImage() -> str - Moves to the next image and returns the current image's URL. previousImage() -> str - Moves to the previous image and returns the current image's URL. startAutoPlay(interval: int) -> None - Begins automatic transitions at the specified interval (in milliseconds). pauseAutoPlay() -> None - Pauses the automatic transitions. resumeAutoPlay() -> None - Resumes the automatic transitions. addImage("https://example.com/image1.jpg", "First image") addImage("https://example.com/image2.jpg", "Second image") followed by nextImage() nextImage() returns the first image's URL and moves the pointer to the second image.class TwitterFeed:def __init__(self): Initializes the Twitter feed object.def post(self, userId: int, tweetId: int) -> None: Posts a tweet for a user.def follow(self, followerId: int, followeeId: int) -> None: Allows follower to follow a followee.def unfollow(self, followerId: int, followeeId: int) -> None: Allows follower to unfollow a followee.def getFeed(self, userId: int) -> List[int]: Retrieves the 10 most recent tweet IDs in the order they were posted.twitter = TwitterFeed() and twitter.post(1, 5) and twitter.follow(1, 2) and twitter.getFeed(1)[5]twitter.post(2, 6)[6, 5]1 <= userId, followerId, followeeId <= 10^40 <= tweetId <= 10^4The operations' total number does not exceed 1000.class LRUCache:def __init__(self, capacity: int): Initializes the LRU Cache with a capacity.def get(self, key: int) -> int: Fetches the value from the cache.def put(self, key: int, value: int) -> None: Updates the cache with a new key-value pair or updates the value if the key exists.cache = LRUCache(2) and cache.put(1, 1) and cache.put(2, 2) and cache.get(1)1cache.put(3, 3)None1 <= capacity <= 30000 <= key, value <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free