Showing 11 questions
Find the shortest string that is not a substring of any string within a given array of strings. Return this shortest uncommon substring.
#1. Shortest Uncommon Substring in an Array
Design a data structure that supports insertion, deletion, and random element retrieval, all in constant time on average. You'll need to handle edge cases carefully to achieve O(1) complexity.
#2. Insert Delete GetRandom O(1)
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#3. Group Anagrams
You're given a Lisp-like expression string. Your task is to evaluate it and return the resulting integer value, following the specific rules of the expression's syntax and scope.
#4. Parse Lisp Expression
Design a hit counter that records hits and retrieves the number of hits in the past 5 minutes. You need to implement methods to record a hit and get the total hits in a sliding window.
#5. Design Hit Counter
Compress a given string by replacing consecutive repeating characters with the character followed by the count of repetitions. If the compressed string isn't shorter, return the original.
#6. String Compression
Design a data structure that supports insert, delete, and getRandom operations, all in constant time, even when duplicate numbers are allowed. The getRandom method should return a random element from the collection with equal probability.
#7. Insert Delete GetRandom O(1) - Duplicates allowed
Determine if two strings are anagrams of each other, meaning they contain the same characters in a different order. You need to check if one string can be rearranged to form the other.
#8. Valid Anagram
Given a set of coin denominations and a target amount, find the minimum number of coins needed to reach that amount. You can assume you have an unlimited supply of each coin type.
#9. Coin Change
You are given a string and a budget for removing characters. Your goal is to compress the string as much as possible after removing at most k characters. Find the length of the shortest possible compressed string.
#10. String Compression III
Design a data structure to record recent function calls. Implement a method to count the number of calls made within the last 3000 milliseconds.
#11. Number of Recent Calls