Largest Value of Usage in Minutes
Reported by candidates from Roblox's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Roblox threw this at candidates in February 2024, and it looks simple until you parse it wrong. You're given device logs as strings in the format "device_id, usage_in_minutes", where the device ID is always five lowercase letters and usage is always a four-digit string. Your job: return the device ID with the highest usage. The trap is treating the usage as a string instead of an integer. StealthCoder will catch that slip if you blank on the parse.
The problem
\ You are given a list of strings data, where each string is in the form\ \"$device_id, $usage_in_minutes\", such that $device_id contains\ exactly five lowercase English letters ('a'-'z') and $usage_in_minutes contains\ exactly four digits, representing a positive integer between 1 and 1440 (possibly with leading zeros).\ \ For instance, \"abxyz, 0010\" describes $device_id = \"abxyz\" and\ $usage_in_minutes = 10 minutes.\ \ Given data, your task is to return the $device_id with the largest\ value of $usage_in_minutes. You may assume that all values of $device_id and\ $usage_in_minutes are both pairwise distinct in data.\Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern here is string parsing plus a max-tracking loop. Split each entry on the comma, extract the usage substring, convert it to an integer, and track the device ID with the largest value. Leading zeros in the usage field (like "0010" for 10 minutes) are a red herring meant to trip up candidates who forget to cast. The algorithm is O(n) with one pass through the data. Edge case: all values are guaranteed distinct, so no tiebreaker logic needed. The real work is getting the parsing right. If you freeze during the live OA, StealthCoder reads the string format on screen and feeds you the correct substring extraction and type conversion pattern immediately.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Largest Value of Usage in Minutes cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Roblox's OA.
Roblox reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Largest Value of Usage in Minutes FAQ
Is this really just max finding with parsing?+
Yes. No sorting, no dynamic programming. Read each entry, extract device ID and usage as an integer, track the max. One loop, O(n) time, O(1) space. The parsing is the only friction point.
Why does the usage have leading zeros?+
To test whether you convert the string to an integer. If you compare strings lexicographically, "0010" looks smaller than "0100", which is wrong. Always parse the usage value as an int before comparison.
What if multiple devices have the same usage?+
The problem statement says all usage values are pairwise distinct, so this won't happen. You don't need a tiebreaker.
Do I need to validate the device ID or usage format?+
No. The problem guarantees exactly five lowercase letters and exactly four digits. Skip validation and focus on the parse and the max loop.
Can I solve this in a functional style or do I need a loop?+
Either works. A simple for loop with a max variable is clearest and fastest to code. If you want a one-liner with map and max, make sure you convert usage to int in the key function.