Solve three DSA problems: trie, window, intervals | Oracle
|Home/Coding & Algorithms/Oracle
Solve three DSA problems: trie, window, intervals
Oracle
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
Design and implement an autocomplete service. Support insert(word) to add a word and suggest(prefix) to return up to five existing words that start with prefix; if fewer than five exist, return all of them. Use a trie-based design; specify the ordering of suggestions (e.g., lexicographic) and the time/space complexities.
You are given two arrays: value[0..n-1] of integers and decrypted[0..n-1] of 0/1 flags (1 means already decrypted), plus an integer k. You may perform at most one operation: choose a contiguous subarray whose length is at most k and treat every index in that subarray as decrypted for scoring. The score is the sum of value[i] over all indices that are decrypted after the operation. Compute the maximum achievable score and provide an O(n) algorithm.
You are given a list of closed integer ranges [li, ri]. Merge any ranges that overlap or touch (i.e., ri >= lj -
and return the merged list sorted by start. Implement the function and analyze its complexity.