Katkat

Solve two coding assessment tasks

SquarepointSoftware Engineer · Online Assessment

Last 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:

  1. 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.

  2. 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.