FastPrepLong-ID Store Without Hashing
Problems/Long-ID Store Without Hashing

Long-ID Store Without Hashing

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem asks for a store of numeric IDs too long for any built-in integer type, with insert, get and delete, and without a hash table. Two Adobe first-round reports describe a get, insert and delete store that must avoid hashing; only one of them says the IDs are too long for built-in types. In both, the candidate first reached for hashing and the interviewer objected that collisions can make each call linear; the candidate in the too-long-ID report then arrived at a trie, which was accepted, while the other report describes no final design. Neither gives a call format, limits or examples, and the other one stores a name with each ID.

Our choices: the calls come as arrays; values are integers from 0 to 10^9 instead of names; an insert replaces, deleting a missing ID does nothing and a missing get returns -1; at most 1000 calls and IDs of up to 40 digits without leading zeros; the no-hashing rule is a stated goal that the judge cannot check; the examples are new.

The judged task matches the reports at about 75%.

Objects are identified by numeric IDs that can be up to 40 digits long, too long for any built-in integer type, so IDs are given as strings of digits. Build a store that starts empty and supports:

  • insert(id, value): store value under id, replacing any value already there.
  • get(id): return the value stored under id, or -1 if there is none.
  • delete(id): remove id and its value; do nothing if it is not stored.

Two IDs are the same only if their digit strings are equal. Call i is operations[i] on ids[i], and values[i] is the value for an insert (0 otherwise). Return the results of the get calls in order.

Goal (not judged): do not use a hash table, and make each call take time proportional to the length of its ID, no matter how many IDs are stored.

Function

runIdStore(operations: String[], ids: String[], values: int[]) → int[]

Examples

Example 1

operations = ["insert","insert","get","delete","get","get"]ids = ["98765432109876543210","98765432109876543211","98765432109876543210","98765432109876543210","98765432109876543210","98765432109876543211"]values = [5,6,0,0,0,0]return = [5,-1,6]

The two IDs differ only in the last digit, and both are too long for a 64-bit integer. After the first is deleted, getting it returns -1, while the second still returns 6.

Example 2

operations = ["insert","insert","get","get"]ids = ["42","42","42","4"]values = [1,7,0,0]return = [7,-1]

Inserting an ID that is already stored replaces its value, so get 42 returns 7. ID 4 was never inserted: -1.

Example 3

operations = ["delete","get","insert","get"]ids = ["5","5","0","0"]values = [0,0,0,0]return = [-1,0]

Deleting a missing ID does nothing. The ID 0 with value 0 is a real entry, so the last get returns 0.

Constraints

  • 1 <= operations.length <= 1000, and ids.length == values.length == operations.length
  • Each operations[i] is "insert", "get" or "delete", and at least one is "get".
  • Each ids[i] is a decimal number of 1 to 40 digits without leading zeros (the single digit "0" is allowed).
  • 0 <= values[i] <= 10^9 for an insert, and values[i] == 0 otherwise.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[] runIdStore(String[] operations, String[] ids, int[] values) {
    // Write your code here.
}
Checking account…