Showing 18 questions
Given two integers and a maximum bit limit, find two numbers within the limit that maximize their bitwise XOR product. Return the maximum possible product modulo a large number.
#1. Maximum Xor Product
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#2. Median of Two Sorted Arrays
Imagine people standing in a queue with varying heights. For each person, determine how many people they can see in front of them (taller people block the view).
#3. Number of Visible People in a Queue
Simulate a simplified Excel sheet and implement the SUM formula. You'll need to parse cell ranges and calculate their sum.
#4. Design Excel Sum Formula
Simulate a spreadsheet. Implement functionality to set cell values and evaluate formulas that depend on other cells.
#5. Design Spreadsheet
You are given equations represented by pairs of variables and their corresponding values. Your task is to evaluate queries based on these equations, determining the value of expressions if possible, or returning -1.0 if not.
#6. Evaluate Division
Find the contiguous subarray within a given array of numbers which has the largest sum. Return the sum of this subarray.
#7. Maximum Subarray
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.
#8. Employee Importance
You're given a sentence and a list of word synonyms. The goal is to generate all possible synonymous sentences by replacing words with their synonyms.
#9. Synonymous Sentences
You are given a list of transactions between people. Determine the minimum number of transactions needed to settle all debts, such that everyone owes or is owed exactly zero.
#10. Optimal Account Balancing
You are given a list of accounts where each account has a name and a list of email addresses. Your task is to merge accounts belonging to the same person based on shared email addresses.
#11. Accounts Merge
You're given two sorted lists. Combine them into a single sorted list containing all elements from both original lists.
#12. Merge Two Sorted Lists
Design and implement a Least Frequently Used (LFU) cache. The cache should allow you to get and put key-value pairs, evicting the least frequently used key when the cache is full.
#13. LFU Cache
You're given a pile of stones with different weights. In each turn, you smash the two heaviest stones together, and the goal is to find the weight of the last remaining stone (or zero if no stone remains).
#14. Last Stone Weight
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#15. Number of Islands
You are given a sorted list of words from an alien language and need to deduce the order of the letters in that language. Determine the alien alphabet order based on the given word sequence.
#16. Alien Dictionary
You're given an initial amount and two conversion rates that change daily. Determine the maximum amount you can have after two days by optimally applying the conversions each day.
#17. Maximize Amount After Two Days of Conversions
Design a data structure that supports insert, delete, and getRandom operations, all in average O(1) time. The getRandom method should return a random element from the current set of elements.
#18. Insert Delete GetRandom O(1)