Showing 12 questions
Traverse a given matrix in a spiral pattern, returning all elements in the order you visit them. Essentially, walk around the matrix layer by layer, adding elements to a list.
#1. Spiral Matrix
Convert a Roman numeral string into its corresponding integer value. The input string will represent a valid Roman numeral.
#2. Roman to Integer
You are given a square matrix representing an image. Rotate the image by 90 degrees clockwise in-place.
#3. Rotate Image
Determine the number of '1' bits present in the binary representation of a given integer. Essentially, count how many bits are set to one.
#4. Number of 1 Bits
Find two numbers in a given array that add up to a specific target value, and return their indices. Essentially, you need to efficiently locate the pair that satisfies the sum requirement.
#5. Two Sum
Determine the total number of continuous subarrays within a given array that sum up to a specific target value, k.
#6. Subarray Sum Equals K
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.
#7. LRU Cache
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#8. Merge Intervals
You are climbing a staircase with n steps. Find how many distinct ways you can climb to the top, given that you can climb one or two steps at a time.
#9. Climbing Stairs
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#10. Longest Substring Without Repeating Characters
Find the kth largest element in an unsorted array. Note that it is the kth largest element in sorted order, not the kth distinct element.
#11. Kth Largest Element in an Array
Find all unique triplets in an array that sum to zero. You'll need to consider the potential for duplicate numbers and avoid duplicate triplets in your solution.
#12. 3Sum