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 7 problems of 27
- #7easysometimes asked
7. Climbing Stairs
Count the distinct ways to climb n stairs taking 1 or 2 steps. Square uses this as a DP primer to see whether you spot the Fibonacci recurrence — and whether you reach for memo or iteration, signalling how you'd handle state machines in their transaction-retry logic.
- #8easysometimes asked
8. Single Number
Find the element that appears once when every other element appears twice. Square uses this to test whether you spot the XOR trick — the same bitwise reasoning their payment-checksum and tamper-detect routines rely on.
- #9easysometimes asked
9. Linked List Cycle
Detect whether a linked list contains a cycle. Square tests Floyd's tortoise-and-hare to gauge pointer dexterity and constant-space thinking — the same care needed when traversing offline transaction journals that may have malformed forward refs.
- #11easysometimes asked
11. Invert Binary Tree
Invert (mirror) a binary tree by swapping every node's left and right child. Square asks this to test whether you can write clean recursive tree code — the same readability they expect in their state-machine traversal code for transaction lifecycles.
- #12easysometimes asked
12. Maximum Depth of Binary Tree
Return the maximum depth of a binary tree. Square uses this as a warm-up to see whether you can write a clean post-order recursion before tackling harder tree problems like balance and path-sum.
- #13easysometimes asked
13. Same Tree
Check whether two binary trees are structurally identical and have equal values. Square uses this to validate that you can write symmetric recursion — same instinct they want when comparing two replicas of an inventory tree during offline sync conflict resolution.
- #14easysometimes asked
14. Symmetric Tree
Determine whether a tree is a mirror image of itself. Square uses this as a sibling problem to Same Tree to see if you can adapt the recursion shape — the kind of pattern transfer they want when porting logic between desktop and mobile POS clients.