Showing 14 questions
Find the k most frequently occurring words in a given list of words. Return the top k words sorted by frequency, and then alphabetically for words with the same frequency.
#1. Top K Frequent Words
Simulate an order processing system with a backlog of buy and sell orders. Determine the total number of orders remaining in the backlog after processing them in a specific manner.
#2. Number of Orders in the Backlog
You're given pairs of adjacent numbers from a hidden array. Reconstruct and return the original array using these pairs.
#3. Restore the Array From Adjacent Pairs
You're given a list of meals, each with a certain deliciousness value. Determine how many pairs of meals have a combined deliciousness that is a power of two.
#4. Count Good Meals
Determine how many strings from a given array only contain characters present in a specified allowed characters string. Count the number of such consistent strings.
#5. Count the Number of Consistent Strings
Imagine houses along a street, each with a brightness level and range of influence. Find the street position with the maximum total brightness from nearby houses.
#6. Brightest Position on Street
Given a grid where each cell represents a street, determine if there's a valid path from the top-left to the bottom-right corner. The street directions must align for a valid path to exist.
#7. Check if There is a Valid Path in a Grid
You're given an array of numbers. Find how many ways you can split it into three non-empty subarrays such that the sum of the first is less than or equal to the second, and the sum of the second is less than or equal to the third.
#8. Ways to Split Array Into Three Subarrays
Find the k most frequent elements in a given array of numbers. Return the top k elements based on their frequency.
#9. Top K Frequent Elements
Play a simplified version of Minesweeper. Given a board with mines, reveal a cell and update the board with numbers indicating adjacent mines.
#10. Minesweeper
Given a sequence of words and a line width, format the text to fit within the specified width. You must justify the text, distributing extra spaces evenly between words.
#11. Text Justification
You're given daily stock prices. Find the maximum profit you can make by buying and selling the stock once. You must buy before you sell.
#12. Best Time to Buy and Sell Stock
Replace the periods in a given IP address with '[.]'. This effectively "defangs" the IP address to prevent accidental clicking.
#13. Defanging an IP Address
You are given a list of employees, each with an ID, importance value, and a list of subordinates' IDs. Find the total importance value of a given employee and all their subordinates in the company hierarchy.
#14. Employee Importance