Showing 12 questions
Find the median of all sliding windows of a given size within an array of numbers. The window slides one position at a time from left to right.
#1. Sliding Window Median
Design a data structure to calculate the moving average of a stream of numbers. The moving average is calculated over a sliding window of a specified size.
#2. Moving Average from Data Stream
You're given user website visit logs. Find the most frequent sequence of three websites visited by any user.
#3. Analyze User Website Visit Pattern
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#4. Longest Substring Without Repeating Characters
Find two numbers in a given array that add up to a specific target value, and return their indices. Essentially, you need to efficiently locate the pair that satisfies the sum requirement.
#5. Two Sum
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#6. Valid Parentheses
Find the kth largest element in an unsorted array. Note that it is the kth largest element in sorted order, not the kth distinct element.
#7. Kth Largest Element in an Array
Determine if a given string is a palindrome, considering only alphanumeric characters and ignoring cases. Essentially, check if the string reads the same forwards and backward after removing non-alphanumeric characters and converting to lowercase.
#8. Valid Palindrome
Determine if you can construct a ransom note from the letters in a magazine. Each letter in the magazine can only be used once.
#9. Ransom Note
Find the maximum depth (number of nodes along the longest path) from the root to a leaf node in a given binary tree. Essentially, you need to determine how 'tall' the tree is.
#10. Maximum Depth of Binary Tree
Imagine a grid representing rooms, some empty, some with walls, and some with gates. Fill each empty room with the distance to its nearest gate.
#11. Walls and Gates
Calculate the nth Fibonacci number. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the previous two.
#12. Fibonacci Number