FastPrepMinimize Distinct Item Types After Removals
Problems/Minimize Distinct Item Types After Removals

Minimize Distinct Item Types After Removals

Roblox logoRoblox● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate names Smart Sales and links the task of getting the fewest unique integers after k removals. This version keeps that goal. We chose the interface with integer labels, the limits, the empty case, and the rule that the input stays unchanged. Our version is about 95% the same as the reported question.

Remove exactly k occurrences from items so that the remaining array has as few distinct item types as possible. Equal integer values represent the same type. Return that minimum number of distinct types.

For this exercise, assume any occurrences may be removed, their order is irrelevant, and the input array must remain unchanged. An empty result has zero types. Negative values and zero are ordinary type labels.

Function

minDistinctAfterRemovals(items: int[], k: int) → int

Examples

Example 1

items = [5,5,4]k = 1return = 1

Remove the lone 4; only type 5 remains.

Example 2

items = [4,3,1,1,3,3,2]k = 3return = 2

Remove the singletons 4 and 2 and one occurrence of another type. Two types remain.

Example 3

items = [7,7]k = 0return = 1

No occurrences are removed, so type 7 remains.

Constraints

  • 0 <= items.length <= 100000.
  • -1000000000 <= items[i] <= 1000000000.
  • 0 <= k <= items.length.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
  • Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025

Similar questions at other companies

  • Count Overlapping Square PairsRamp · OARamp interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Two Tribes from Taller-Person CountsIntuit · OAIntuit interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Get Triplet CountIBM · OAIBM interview questions
  • Count Reverse-Digit PairsVisa · OAVisa interview questions
  • Count 2x2 Submatrices by Black CellsTikTok · OATikTok interview questions

Interview reports that mention this question

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int minDistinctAfterRemovals(int[] items, int k) {
        // write your code here
    }

}
Checking account…