Skip to main content

Square Coding Interview Questions

27 Square coding interview problems with full optimal solutions — 18 easy, 7 medium, 2 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Square interviewer values, and a FAQ section.

Showing 11 problems of 27

  • #15easyfoundational

    15. Two Sum II - Input Array Is Sorted

    Given a sorted list of settled transaction amounts, find two that match a target refund — Square's refund-matching engine does exactly this to pair a chargeback against two split payments without rescanning the ledger.

  • #16easyfoundational

    16. Valid Anagram

    Determine whether two merchant category codes are permutations of each other — Square's risk team uses character-frequency checks to detect look-alike merchant names that attempt to spoof category routing.

  • #17easyfoundational

    17. First Bad Version

    Find the first firmware release that broke POS terminal compatibility — Square ships hundreds of hardware versions and uses binary search to pinpoint the exact SDK version that introduced a payment-flow regression without re-running every build.

  • #18easyfoundational

    18. Move Zeroes

    Push zero-amount line items to the end of a POS receipt array while keeping non-zero charges in order — Square's receipt-rendering pipeline compacts voided items in-place before printing, without allocating a second buffer.

  • #1easyfrequently asked

    1. Two Sum

    Given an array of integers and a target, return indices of two numbers that add up to the target. Square asks this as a warm-up to gauge whether you reach for hash maps the moment lookup-by-value enters the picture — a habit that scales into their transaction-matching code.

  • #2easyfrequently asked

    2. Valid Parentheses

    Given a string of brackets, decide whether it is well-formed. Square uses this to check whether you reach for a stack the instant 'matching' enters the picture — the same instinct they want when reconciling open transactions against captures.

  • #3easyfrequently asked

    3. Merge Two Sorted Lists

    Splice two sorted linked lists into one sorted list. Square uses this to test pointer-discipline — the same care needed when reconciling two ordered streams of transaction events for offline-first sync.

  • #4easyfrequently asked

    4. Best Time to Buy and Sell Stock

    Find the max profit from one buy and one sell over a price array. Square uses this to test whether you spot the single-pass running-minimum pattern — the same trick they apply to compute peak-vs-trough deltas on Cash App balance histories.

  • #5easyfrequently asked

    5. Contains Duplicate

    Given an array, return whether any value appears at least twice. Square uses this trivial-seeming problem as a habit check — they want the Set reach, not a nested loop, because their idempotency-key pipelines depend on the same instinct.

  • #6easyfrequently asked

    6. Maximum Subarray

    Find the contiguous subarray with the largest sum. Square tests Kadane's algorithm because the same running-state pattern shows up in their net-flow reconciliation jobs where you want the best contiguous window of debits vs credits.

  • #10easyfrequently asked

    10. Reverse Linked List

    Reverse a singly linked list. Square uses this to test that you can manipulate next-pointers without losing nodes — the same discipline they expect when replaying out-of-order event logs during offline-to-online POS sync.

Square Coding Interview Questions — Full Solutions — InterviewChamp.AI