Showing 10 questions
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.
#1. String Compression
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#2. Merge Intervals
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#3. Group Anagrams
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.
#4. LRU Cache
Calculate a new array where each element is the product of all numbers in the original array, excluding the number at that index. Do this efficiently without using division.
#5. Product of Array Except Self
Track and query the fluctuating price of a stock. You need to efficiently find the latest price and the highest price recorded so far.
#6. Stock Price Fluctuation
Determine the total number of continuous subarrays within a given array that sum up to a specific target value, k.
#7. Subarray Sum Equals K
Implement a basic calculator to evaluate a simple expression string. The expression can contain parentheses, addition, and subtraction.
#8. Basic Calculator
Koko wants to eat all the bananas in some piles within a certain time. Find the minimum eating speed that allows her to finish on time.
#9. Koko Eating Bananas
Find the contiguous subarray within a given array of numbers which has the largest sum. Return the sum of this subarray.
#10. Maximum Subarray