Showing 12 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
Implement an iterator that cycles through multiple lists in a zigzag pattern. The iterator should return elements from each list in turn until all elements are exhausted.
#2. Zigzag Iterator
Design a key-value store that supports storing values associated with timestamps. You should be able to retrieve the value for a given key at the latest timestamp less than or equal to a given time.
#3. Time Based Key-Value Store
Implement an in-memory file system with basic operations like creating directories, adding files, and listing contents. The file system should support path-based navigation.
#4. Design In-Memory File System
You are given a secret code and a message. Use the code to decipher the message by substituting characters according to the given key.
#5. Decode the Message
Design a file system that allows you to create paths and associate values with them. Implement operations to create new paths and retrieve the value associated with a path.
#6. Design File System
Determine if an array can be divided into subarrays where each subarray satisfies certain conditions (equal elements or specific increasing sequences). The goal is to check if a valid partition exists based on these rules.
#7. Check if There is a Valid Partition For The Array
Given a sequence of words and a line width, format the text to fit within the specified width. You must justify the text, distributing extra spaces evenly between words.
#8. Text Justification
You're given an array representing weights. Implement a function to randomly pick an index from the array, where the probability of picking each index is proportional to its weight.
#9. Random Pick with Weight
Simulate an order processing system with a backlog of buy and sell orders. Determine the total number of orders remaining in the backlog after processing them in a specific manner.
#10. Number of Orders in the Backlog
You are given equations represented by pairs of variables and their corresponding values. Your task is to evaluate queries based on these equations, determining the value of expressions if possible, or returning -1.0 if not.
#11. Evaluate Division
Find the longest common prefix string amongst an array of strings. Return the length of this common prefix.
#12. Find the Length of the Longest Common Prefix