Square logo

Square Software Engineer Coding Questions

15 practice questions for Square Software Engineer interviews

Square software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Medium Verified Question #1

1. Connect Four


Category: Grid/matrix coding problem

Question Design a ConnectFour class that implements the Connect Four board game. The board is a 6-row by 7-column grid. Two players take turns...

Input: 2D grid
Output: Printed output
coding Medium Verified Question #2

2. Page Navigator


Category: Sliding window coding problem

Question Design a PageNavigator class that simulates a paginated view with a sliding window. Given a total number of pages and a window size, the...

Input: List
Output: Computed result
coding Medium Verified Question #3

3. Grid Exits


Category: Grid/matrix coding problem

Question You are given a 2D grid containing open cells (".") and walls ("#"). An exit is any open cell on the border of the grid that is...

Input: 2D grid
Output: Integer
coding Medium Verified Question #4

4. Item Price Manager


Category: Algorithm coding problem

Question Design an ItemPriceManager class that tracks the price history of an item over time and supports querying the price at any date and the...

Input: Given input
Output: Computed result
coding Easy Verified Question #5

5. Pig Latin Translator


Category: Algorithm coding problem

Question Translate a sentence into Pig Latin using the following rules: Rules: 1. If a word begins with a vowel (a, e, i, o, u),...

Input: Given input
Output: Computed result
coding Medium Verified Question #6

6. Frequency Merge Tree


Category: Tree coding problem

Question Given a string, build a Frequency Merge Tree as follows: 1. Count the frequency of each character in the string. 2. Create a leaf node...

Input: String
Output: Computed result
coding Easy Verified Question #7

7. Obstacle Grid Blocks


Category: Grid/matrix coding problem

Question You are given two integers R and C representing the number of rows and columns in a grid (0-indexed). You are also given a list...

Input: 2D grid
Output: Computed result
coding Medium Verified Question #8

8. Soccer Tournament Tracker


Category: String coding problem

Question

Input: Array of strings
Output: Array
coding Easy Verified Question #9

9. Candy Bag Matcher


Category: String coding problem

Question

Input: Array of strings
Output: Array
coding Medium binary search #1

1. Binary Search — Find the square root of a number

Background: In the payment processing system at Square, efficient mathematical computations can enhance performance and accuracy. Finding the square root of numbers can be critical in calculations involving rates and fees.
Problem statement: Given a non-negative integer x, implement a function that returns the integer part of the square root of x. The square root is defined as the number y such that y * y <= x < (y + 1) * (y + 1). You should implement this using binary search.
Function signature:
  • def my_sqrt(x: int) -> int:


Example 1:
  • Input: x = 8

  • Output: 2

  • Explanation: The square root of 8 is 2.828..., so the integer part is 2.


Example 2:
  • Input: x = 16

  • Output: 4

  • Explanation: The square root of 16 is 4.


Constraints:
  • 0 <= x <= 2 * 10^9
coding Medium heap #2

2. [Heap] — Find the k most frequent elements in a dataset

Background: Square handles significant financial data and user transactions where analyzing trends is crucial for strategic decisions. Identifying the most frequent elements from a set of transactions can help in understanding the most popular features or identifies patterns in user behavior.
Problem statement: Given a list of integers, nums, representing transaction IDs, and an integer k, return the k most frequent elements. You need to implement the function topKFrequent(nums: List[int], k: int) -> List[int].
Function/class signature:
  • def topKFrequent(nums: List[int], k: int) -> List[int]:

Example 1:
  • Input: nums = [1,1,1,2,2,3], k = 2

  • Output: [1, 2]

  • Explanation: 1 appears three times, while 2 appears twice. Therefore, the top two frequent elements are 1 and 2.

Example 2:
  • Input: nums = [1], k = 1

  • Output: [1]

  • Explanation: Since there’s only one element, 1, it is the only frequent element.

Constraints:
  • 1 <= nums.length <= 10^5

  • 0 <= nums[i] < 10^4

  • 1 <= k <= number of unique elements in the array


Related Square Software Engineer interview prep

Start practicing Square questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free