Question Your task is to implement a simple in-memory cloud storage system that maps objects (files) to their metadata (name, size, etc.). You...
Input: Graph (nodes and edges) Output: Array
codingMediumreact#1
1. React Coding Challenge — Fix errors in a React application
Background: Ramp is focused on building efficient financial solutions, often utilizing React for front-end development. A robust front-end directly impacts user experience in their product offerings. Problem statement: You are given a simple React application that displays user transactions but contains several errors. Your task is to identify and fix these errors. The React component should properly render a list of transactions with each transaction's title, amount, and date. The issues may include improper state management or incorrect JSX syntax. Function/class signature:
function TransactionList({ transactions }: { transactions: Transaction[] }): JSX.Element;
Output: Renders one transaction with the title 'Utilities', amount -300, and the date formatted correctly.
Constraints:
Maximum of 100 transactions.
Amount values can be positive (income) or negative (expenses).
codingMediumhash map#2
2. Coding — Find Missing Transactions in a Payment System
Background: Ramp operates in the finance and payment processing space, where ensuring data integrity and identifying discrepancies in transaction records is crucial. This problem relates directly to their transactional data processing systems. Problem statement: You are given two lists of transactions: current and previous. Each transaction is represented by a unique identifier. Your task is to identify the transactions that are in current but not in previous. Return a list of the missing transaction IDs in ascending order. Function/class signature:
Input: current = ['trans1', 'trans2', 'trans3'], previous = ['trans1', 'trans2']
Output: ['trans3']
Explanation: Transaction 'trans3' is present in the current list but not in the previous list.
Example 2:
Input: current = ['trans4', 'trans5', 'trans6'], previous = ['trans4', 'trans6']
Output: ['trans5']
Explanation: Transaction 'trans5' is the only record that is in current but not in previous.
Constraints:
1 <= len(current), len(previous) <= 10^6
Transaction IDs are unique strings with a maximum length of 100 characters.
codingMediumhash map#3
3. Coding — Identify and correct errors in a React application
1. Background: At Ramp, maintaining a high-quality user interface in our financial tools is crucial. React is widely used for building dynamic web applications, and debugging is a common challenge that impacts user experience. 2. Problem statement: You are tasked with reviewing a snippet of a React application that is supposed to render a list of transactions. However, it contains several mistakes that prevent it from functioning properly. Your goal is to identify these errors and suggest necessary corrections. The code snippet is as follows:
3. Function/class signature: - TransactionList(transactions: Array<Transaction>): JSX.Element 4. Example 1: - Input: [{id: 1, description: 'Purchase', amount: '$50'}, {id: 2, description: 'Refund', amount: '$25'}] - Output: <ul><li>Purchase$50</li><li>Refund$25</li></ul> - Explanation: The component correctly maps over the transactions and displays each one in a list item. 5. Example 2: - Input: [] - Output: <ul></ul> - Explanation: An empty transaction array should render an empty list. 6. Constraints: - The transactions array can contain up to 1000 transaction objects. - Each transaction object must have id, description, and amount properties, where id is a unique number. - description and amount are strings.
codingMediumsliding window#4
4. Longest Substring Without Repeating Characters — Find the length of the longest substring that contains no repeating characters
Background: In Ramp's financial tools, analyzing unique sets of transactions is crucial for generating accurate reports. Efficiently finding unique sequences of transactions can help improve data processing and increase user satisfaction. Problem statement: Given a string s, find the length of the longest substring without repeating characters. For instance, in the case of transaction records represented as a string, the goal is to identify the longest section of unique transaction types. Function/class signature:
def length_of_longest_substring(s: str) -> int:
Example 1:
Input: s = "abcabcbb"
Output: 3
Explanation: The longest substring without repeating characters is "abc", which has a length of 3.
Example 2:
Input: s = "bbbbb"
Output: 1
Explanation: The longest substring is "b", with a length of 1.
Constraints:
0 <= s.length <= 1000
s consists of English letters, digits, symbols and spaces.
codingMediumtree#5
5. [Tree] — Find the height of a binary tree
Background: In the context of Ramp’s financial services platform, scalable data structures are crucial for efficiently handling user transactions and account balances. Understanding the organization of user data within a binary tree can provide insights for optimizing search and transaction algorithms in their systems.Problem statement: Given a binary tree, you need to implement a method to determine its height. The height of a binary tree is defined as the number of edges on the longest downward path between the root node and a leaf node. You have to calculate the height by traversing the tree nodes.Function/class signature:
def tree_height(root: Optional[TreeNode]) -> int:
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: 2
Explanation: The tree structure is:
3
/ \
9 20
/ \
15 7
The height is 2 because the longest path from the root (3) to the leaf nodes (9 or 15/7) contains 2 edges.Example 2:
Input: root = [1,null,2]
Output: 1
Explanation: The tree structure is:
1
\
2
The height is 1 because the only path from the root (1) to the leaf node (2) contains 1 edge.Constraints:
The number of nodes in the tree is in the range [0, 10^4].
-100 <= Node.val <= 100.
system designMediumdatabase#6
6. Design DatabaseManager — a class to manage a simple database with basic operations
Background: Ramp's financial services require efficient data handling and management to track transactions and user data effectively. This class will help manage a database's basic functionalities like adding, removing, and handling ownership of records. Requirements: 1. The DatabaseManager class should allow for adding new records. 2. It must support removing existing records by ID. 3. Implement a method to add ownership to specific records for users. 4. Create a method to retrieve a record by its ID. 5. Records should be stored in memory for quick access. Class API:
add_record(record: Dict[str, Any]) -> None - Adds a new record.
remove_record(record_id: str) -> None - Removes a record by its unique ID.
add_ownership(record_id: str, owner_id: str) -> None - Assigns ownership to a user.
get_record(record_id: str) -> Optional[Dict[str, Any]] - Retrieves a record by its ID.
Example 1:
Input: add_record({'id': '1', 'name': 'Transaction1'}) → Output: None → Explanation: A new record with ID '1' is added.