Rivian Interview Questions
Showing 9 questions
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.
#1. LRU Cache
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#2. Number of Islands
Determine if a string can be rotated to match another string. You're essentially checking if one string is a shifted version of the other.
#3. Rotate String
Find the smallest subarray within a given array that has the same degree as the entire array. The degree is defined as the highest frequency of any element.
#4. Degree of an Array
The problem requires you to flatten a deeply nested array into a single-level array. You need to handle arrays containing other arrays at various levels of nesting.
#5. Flatten Deeply Nested Array
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#6. Merge Intervals
You are given k sorted lists. Combine all of their elements into a single sorted list and return it.
#7. Merge k Sorted Lists
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.
#8. String Compression
Imagine a city grid of buildings. Find the maximum total height increase you can make to the buildings while maintaining the original skyline from all four sides.
#9. Max Increase to Keep City Skyline