Solve two coding assessment tasks
SquarepointSoftware Engineer · Online AssessmentLast updated
This question set evaluates algorithmic optimization and string-processing skills: the first problem focuses on maximizing cumulative revenue from limited inventories (optimization and greedy reasoning with dynamic value updates), while the second focuses on case-insensitive text parsing, word frequency counting, and frequency-based ordering.
The online assessment contained two coding problems:
-
Maximize store revenue You are given an integer array
quantityof lengthn, wherequantity[i]is the current inventory of producti. Selling one unit of productiearns revenue equal to its current inventory immediately before the sale. After the sale,quantity[i]decreases by 1. There aremcustomers, and each customer buys exactly one unit. Assume0 <= 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.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.