6 data structures and algorithms questions6 Interview Questions
Transform one word into another, one letter at a time, using only words from a given dictionary. Find the shortest sequence of words to reach the target.
#1. Word Ladder
You're given a budget and prices for pens and pencils. Determine how many different combinations of buying pens and pencils you can afford within your budget.
#2. Number of Ways to Buy Pens and Pencils
Design a data structure that acts as a Least Recently Used (LRU) cache. Implement methods to get and put key-value pairs, evicting the least recently used entry when the cache is full.
#3. LRU Cache
Design a hit counter to track the number of hits recorded in the past 5 minutes. Implement methods to record a hit and retrieve the total hits in the past 5 minutes.
#4. Design Hit Counter
Design a logger that prevents duplicate messages from being printed within a certain time window. Determine if a message should be printed based on its timestamp and content, considering rate limiting.
#5. Logger Rate Limiter
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#6. Number of Islands