FastPrepLicense Checkout and Return Manager
Problems/License Checkout and Return Manager

License Checkout and Return Manager

Headway logoHeadway● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Headway phone screen. The report describes Karat checkoutLicense and returnLicense functions. We chose the license numbering, who owns a license, which license is picked, how repeats and errors work, and the fixed list of operations. The report does not say what the debugging bug was. Our version is about 75% the same as the reported question.

Implement a license checkout manager for the listed operations. A pool of capacity licenses is shared by users. Process each string in operations in order; it is either checkout,userId or return,userId.

For this exercise, assume licenses are numbered 1 through capacity and each user may hold at most one license. If the user already holds a license, checkout returns that same license; otherwise it assigns the smallest available license. When none is free, return -1.

For this exercise, assume return releases the requesting user's current license and returns its identifier. If that user has no license, return -1 without changing the pool. Operations are sequential and licenses do not expire.

For this exercise, assume operations are valid, contain exactly one comma without spaces, and user identifiers are nonempty case-sensitive alphanumeric strings. Return one integer for each operation; an empty sequence produces an empty result.

Function

licenseOperations(capacity: int, operations: String[]) → int[]

Examples

Example 1

capacity = 2operations = ["checkout,amy","checkout,bob","checkout,cat","return,amy","checkout,cat"]return = [1,2,-1,1,1]

Amy receives 1, Bob 2, and the full pool rejects Cat. Returning Amy frees 1 for Cat.

Example 2

capacity = 1operations = ["checkout,u","checkout,u","return,u","return,u"]return = [1,1,1,-1]

Repeat checkout reuses the same lease; after one successful return, another return has no lease to release.

Constraints

  • For this exercise, assume 0 <= capacity <= 10^4.
  • 0 <= operations.length <= 10^4.
  • User identifier lengths are from 1 through 30.
  • Actions are exactly checkout or return.

More Headway Phone Screen questions

  • Phone-Number Letter CombinationsPHONE SCREEN · Seen Oct 2026
  • Hierarchical Fixed-Window Rate LimiterPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Financial Account LedgerStripe · OA · PHONE SCREENStripe interview questions
  • Paged KV Cache AccessNVIDIA · PHONE SCREENNVIDIA interview questions
  • Key-Value Store on a Block DeviceLambda · PHONE SCREEN
  • Risk-Priority Detection StoreCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Design Authentication ManagerApple · PHONE SCREENApple interview questions
  • LLM Provider Pool FailoverPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • 15-Minute Chat Session TrackerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Capacity-Limited Timed CacheNetflix · PHONE SCREENNetflix interview questions
  • Tiered Expiring Item StoreHudson River Trading · PHONE SCREEN · ONSITE INTERVIEWHudson River Trading interview questions

Headway interview experiences

  • Headway Karat 1st Interview Round (Same for all level)
All Headway interview questionsSee Headway hiring insights
Saved
class Solution {
    public int[] licenseOperations(int capacity, String[] operations) {
        // Write your code here.
        return new int[0];
    }
}
Checking account…