Square software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for Square.
sync can do so. All orders must be created before operations referencing them are queued."QUEUED". Reusing an ID with exactly the same terminal, operation type, order, amount, and referenced payment returns "DUPLICATE", without re-enqueuing it. Reusing it with any different field returns "CONFLICT". Retain IDs even after rejection. For a previously seen operation ID, perform this identity check before validating the new payload.sync(device_id) processes that terminal's pending operations in FIFO order and removes them from its queue. A payment is applied only if captured_cents + amount_cents <= total_cents; otherwise reject it with "PAYMENT_LIMIT". Accept or reject the entire operation, never a portion. When terminals compete, the order in which sync is called determines the winner."UNKNOWN_PAYMENT". Refunds against one payment may cumulatively total at most its captured amount; exceeding that amount produces "REFUND_LIMIT". Successful operations return "APPLIED". Rejections are final: a corrected attempt requires a new operation ID.due_cents = total_cents - captured_cents, and net_cents = captured_cents - refunded_cents. Each sync returns a list of {"operation_id": string, "status": string} results. Syncing an empty or unknown terminal returns []. Returned results and order snapshots must not expose mutable internal state.ValueError without changing state. A refund may be queued before its referenced payment exists. Methods execute sequentially; synchronization is explicit, synchronous, and has no simulated transport failures.Class APIOfflinePOS() — Construct an empty merchant reconciliation model.create_order(order_id: str, total_cents: int) -> None — Register an order; duplicate order IDs are invalid.queue_payment(device_id: str, operation_id: str, order_id: str, amount_cents: int) -> str — Queue a payment, returning QUEUED, DUPLICATE, or CONFLICT.queue_refund(device_id: str, operation_id: str, order_id: str, payment_id: str, amount_cents: int) -> str — Queue a refund with the same enqueue-result semantics.sync(device_id: str) -> list[dict[str, str]] — Reconcile and drain one terminal's queue.get_order(order_id: str) -> dict[str, int] — Return total_cents, captured_cents, refunded_cents, due_cents, and net_cents.[
{"method": "create_order", "args": ["order-1", 1000]},
{"method": "queue_payment", "args": ["terminal-A", "pay-1", "order-1", 600]},
{"method": "queue_payment", "args": ["terminal-B", "pay-2", "order-1", 500]},
{"method": "sync", "args": ["terminal-A"]},
{"method": "sync", "args": ["terminal-B"]},
{"method": "queue_payment", "args": ["terminal-B", "pay-3", "order-1", 400]},
{"method": "sync", "args": ["terminal-B"]},
{"method": "get_order", "args": ["order-1"]}
][
null,
"QUEUED",
"QUEUED",
[{"operation_id": "pay-1", "status": "APPLIED"}],
[{"operation_id": "pay-2", "status": "PAYMENT_LIMIT"}],
"QUEUED",
[{"operation_id": "pay-3", "status": "APPLIED"}],
{"total_cents": 1000, "captured_cents": 1000, "refunded_cents": 0, "due_cents": 0, "net_cents": 1000}
]send_notification(user_id: str, message: str, notification_type: str) -> bool set_preferences(user_id: str, preferences: dict) -> None get_status(notification_id: str) -> dict flush_queue() -> None send_notification('userA', 'Your payment was successful!', 'email') → Output: True → Explanation: The notification is queued successfully.Example 2: set_preferences('userA', {'email': False, 'SMS': True}) → Output: None → Explanation: User preferences are updated without error.Constraints: add_payment_method(method: str) -> None: Adds a new payment method to be supported.process_payment(transaction_id: str, amount: float, method: str) -> str: Processes a payment and returns the transaction status.get_transaction_status(transaction_id: str) -> str: Retrieves the status of a given transaction.get_transaction_history() -> List[Dict[str, Any]]: Returns a list of all transactions.add_payment_method("Credit Card") → Output: None → Explanation: Adds "Credit Card" as a valid payment method.process_payment("txn_123", 100.00, "Credit Card") → Output: "Success" → Explanation: Processes a payment for 100.00 using the credit card method.class BankAccount: - represents an individual user account.def __init__(self, account_id: str, initial_balance: float) -> None: - initializes a new account with a unique ID and balance.def deposit(self, amount: float) -> str: - deposits a specified amount into the account.def withdraw(self, amount: float) -> str: - withdraws a specified amount from the account.def get_balance(self) -> float: - returns the current balance of the account.Example 1:account = BankAccount('12345', 100.0); account.deposit(50.0); account.withdraw(30.0)account.get_balance() → 120.0account = BankAccount('67890', 200.0); account.withdraw(250.0)account.get_balance() → 200.0account_id must be a unique string.initial_balance must be a non-negative float.amount for deposits and withdrawals must be a positive float.class User: Represents a bank user.def __init__(self, user_id: str, name: str) -> None: Initializes a new user with ID and name.def deposit(self, amount: float) -> None: Deposits a specified amount into the user's account.def withdraw(self, amount: float) -> None: Withdraws a specified amount from the user's account.class Transaction: Represents a transaction in the banking system.def __init__(self, user_id: str, amount: float, type: str) -> None: Initializes a new transaction with user ID, amount, and type (deposit/withdraw).class Bank: Main class for interaction.def create_user(self, name: str) -> User: Creates a new user.def transfer(self, from_user: User, to_user: User, amount: float) -> None: Transfers funding between users.Example 1:Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free