The online assessment contained two coding problems:
-
Maximize store revenue
You are given an integer array
quantity
of length
n
, where
quantity[i]
is the current inventory of product
i
. Selling one unit of product
i
earns revenue equal to its current inventory immediately before the sale. After the sale,
quantity[i]
decreases by 1. There are
m
customers, and each customer buys exactly one unit. Assume
0 <= m <= sum(quantity)
. Choose which product to sell to each customer so that the total revenue is maximized. Return the maximum possible revenue.
-
Find top word frequencies
You are given a string
text
. Count how many times each word appears, treating uppercase and lowercase letters as the same. A word is defined as a maximal sequence of English letters, and any non-letter character should be treated as a separator. Return at most 3 distinct words, sorted by descending frequency. If two words have the same frequency, sort them in ascending alphabetical order. If the text contains fewer than 3 distinct words, return all of them.