CodeSignal OAs software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
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)Question Design a banking system that supports account management, transactions, and various financial operations.
Input: Graph (nodes and edges)Description Implement a simplified in-memory database that supports record manipulation with various operations. The system should handle basic...
Input: Graph (nodes and edges)OA [CodeSignal] Adventure Levels You start with initial energy K. You need to clear a series of adventure levels. For each level i: -...
OA [CodeSignal] Balanced Numbers in Permutation Given a permutation p of integers from 1 to n. A number k (where 1 <= k <= n) is called...
n nodes where each node has a lowercase English character c[i]. A path is palindromic if the characters along the path can...Input: Listthroughput[i] - Cost to scale up by 1 unit scalecost[i] You have a fixed...Input: Listprices: array of...Input: Arrayn. You can use either the lift or stairs. Lift: - Takes t1 time per floor -...Input: Given inputQuestion You are monitoring the building density in a district of houses. The district is represented as a number line, where each house is located...
Input: Array of integersn days. The...Input: Arraycustomer_rating is maintained for the...Input: ArrayKnowledgeBaseSystem that stores articles with CRUD operations. The system operates entirely...Input: Graph (nodes and edges)n broadcast stages, numbered 1 to n, arranged in a perfect binary tree rooted at stage 0. Each stage...Input: Binary treeheights representing a histogram. Bar i occupies the horizontal interval [i, i + 1], has height heights[i], and rests on a shared baseline at height zero.Find the maximum area of an axis-aligned square that fits entirely beneath the histogram. The square's bottom edge must lie on the baseline, and its left and right edges must have integer horizontal coordinates.Equivalently, a square with integer side length s fits if there are at least s consecutive bars, each with height at least s. Return its area, s * s. Return 0 if no positive-area square fits.Your implementation must run in O(n) time, where n is the number of bars.Function or class signaturelargest_square_area(heights: list[int]) -> intheights = [2, 4, 4, 4, 1]91, 2, and 3 support a square of side 3, giving area 3 * 3 = 9. A square of side 4 would require four consecutive bars of height at least 4, which do not exist.heights = [5, 5]42. The largest square has side 2 and area 4.1 <= len(heights) <= 200000.0 <= heights[i] <= 1000000000.1.(area, left_index, side_length) identifying an optimal square. Among equally large squares, choose the smallest left_index; return (0, -1, 0) when no positive-area square exists. Can you preserve O(n) time?false. Deposits accept nonnegative amounts and return the updated balance, or null if the account does not exist.null without changing balances or spending totals.pay immediately debits a positive amount from an existing account with sufficient funds. Successful payments receive globally sequential IDs payment1, payment2, and so on; failed payments return null and do not consume an ID. Each successful payment schedules cashback of floor(amount * 2 / 100) cents exactly 86,400,000 milliseconds later.IN_PROGRESS to CASHBACK_RECEIVED. Zero-cent cashback still changes the status. All call timestamps are strictly increasing.top_spenders returns up to n strings formatted as account_id(total), ordered by descending outgoing total and then ascending account ID. Include accounts with zero outgoing total when needed.null if the account or payment does not exist, or the payment belongs to another account. Apart from processing already-due cashback, failed operations must leave state unchanged.Class APIBankingSystem() — construct an empty system.create_account(timestamp: int, account_id: str) -> bool — create an account with zero balance.deposit(timestamp: int, account_id: str, amount: int) -> Optional[int] — deposit cents and return the new balance.transfer(timestamp: int, source_id: str, target_id: str, amount: int) -> Optional[int] — transfer cents and return the source balance.pay(timestamp: int, account_id: str, amount: int) -> Optional[str] — debit a payment and schedule cashback.get_payment_status(timestamp: int, account_id: str, payment_id: str) -> Optional[str] — return the owned payment's status.top_spenders(timestamp: int, n: int) -> List[str] — return the requested spender ranking.[ ["create_account", 1, "a"], ["create_account", 2, "b"], ["deposit", 3, "a", 1000], ["transfer", 4, "a", "b", 200], ["pay", 5, "a", 300], ["top_spenders", 6, 2], ["deposit", 86400004, "a", 0], ["get_payment_status", 86400005, "a", "payment1"], ["deposit", 86400006, "a", 0] ]
[true, true, 1000, 800, "payment1", ["a(500)", "b(0)"], 500, "CASHBACK_RECEIVED", 506]
a spends 200 + 300 = 500 cents. Its payment cashback is floor(300 * 2 / 100) = 6 cents, due at 5 + 86400000 = 86400005. The balance is 500 immediately before that timestamp and 506 afterward.Example 2:[ ["create_account", 1, "z"], ["deposit", 2, "z", 49], ["pay", 3, "z", 49], ["create_account", 4, "a"], ["top_spenders", 5, 2], ["get_payment_status", 6, "a", "payment1"], ["pay", 7, "z", 1], ["get_payment_status", 86400003, "z", "payment1"], ["deposit", 86400004, "z", 0] ]
[true, 49, "payment1", true, ["z(49)", "a(0)"], null, null, "CASHBACK_RECEIVED", 0]
a cannot inspect z's payment. Account z has no remaining funds for the second payment. Its original cashback is floor(49 * 2 / 100) = 0, but the status still changes at the due timestamp.Constraints100,000 public method calls and 10,000 accounts; calls are sequential, with no concurrency or persistence requirement.[1, 10^15], measured in milliseconds. No background thread is required: process due events when a method is called.[0, 10^9]; transfers and payments are in [1, 10^9]. Ranking requests satisfy 0 <= n <= 10,000.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free