Okta Interview Questions
Showing 13 questions
Simulate a simple bank system that supports basic operations like deposit, withdraw, and check balance for different accounts. You will implement methods to handle these transactions and ensure validity based on account balances and existence.
#1. Simple Bank System
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.
#2. LRU Cache
Find all nodes in a binary tree that are exactly K distance away from a given target node. The distance is measured by the number of edges between the nodes.
#3. All Nodes Distance K in Binary Tree
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.
#4. Insert Delete GetRandom O(1)
Design a data structure that efficiently finds the median of a dynamically growing stream of numbers. You need to implement methods to add new numbers and quickly retrieve the current median.
#5. Find Median from Data Stream
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. These consecutive numbers do not need to be adjacent in the original array.
#6. Longest Consecutive Sequence
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#7. Merge Intervals
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#8. Median of Two Sorted Arrays
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
You are given an array representing the heights of vertical lines. Find two lines that, together with the x-axis, form a container that holds the most water.
#10. Container With Most Water
Given a list of daily temperatures, find how many days you have to wait until a warmer temperature. Return a list where each element represents the waiting days for each day's temperature.
#11. Daily Temperatures
Determine if any two strings in a given list differ by exactly one character. Return true if such a pair exists, and false otherwise.
#12. Strings Differ by One Character
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#13. Number of Islands