I participated in this article Shopify Review of real test questions after CoderPad Assessment. Several offer processes were being processed at the same time, leaving only three days left for Shopify. The time was very limited. Fortunately, the last three parts were all passed. Three days later, I received an email from HR and entered the next round. This article sorts out the questions and ideas encountered and provides reference for those preparing for the exam later.

Shopify OA Basics
- Platform:CoderPad (built-in SQL environment)
- Structure: Algorithm programming + logical reasoning + SQL data analysis, three parts
- Total duration: About 90 minutes, three parts can be switched freely
- Difficulty:Algorithm LeetCode easy~medium, SQL medium, logical reasoning partial to business
Shopify coderpad assessment questions
Algorithm part
Real question 1: The longest valid bracket
Topic:
Given a string consisting only of
(And), find the length of the longest valid parentheses substring.
Corresponding to LeetCode #32, it looks simple, but there are many pitfalls in boundary conditions.
Problem-solving ideas:
Using stack record index, encounter ( Push into the stack and encounter ) To pop the stack, subtract the top index from the current index to get the current effective length.
Def longestValidParentheses(s):
stack = [-1]
ans = 0
for i, ch in enumerate(s):
if ch == '(':
stack.append(i)
else:
stack.pop()
if not stack:
stack.append(i)
else:
ans = max(ans, i - stack[-1])
return ans
Pitfalls:
- Stack initialization put
-1It's to handle situations where it's legal from the beginning, don't miss it. )After popping the stack, the stack is empty, and a current index needs to be added as the new baseline.- Shopify attaches great importance to code readability. Write variable names clearly and add one or two lines of comments.
Real question 2: Combined delivery time intervals
Topic:
Given a list of delivery time intervals
(start, end), merge all overlapping intervals.
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Corresponds to LeetCode #56, classic merge interval.
Problem-solving ideas:
First sort by the starting point, and then traverse. If it can be merged, merge it. If it cannot be merged, open a new interval.
Def mergeIntervals(intervals):
intervals.sort(key=lambda x: x[0])
merged = []
for interval in intervals:
if not merged or merged[-1][1] < interval[0]:
merged.append(interval)
else:
merged[-1][1] = max(merged[-1][1], interval[1])
return merged
Pitfalls:
- This step of sorting cannot be omitted, otherwise the subsequent merging logic will be completely wrong.
- Take when merging
MaxRather than covering it directly, because there may be cases of complete inclusion, such as[1,10]And[2,5]
Real question three: Beverage bundle pricing
Topic:
Given a set of order records, the format is
["date", "item"]. Rules: Buy popcorn and soda at the same time on the same day, try to pair them up for a bundle price of $9; buy soda alone for $2.5, and buy popcorn alone for $8. Calculate total price.
Input:
[["10212021", "popcorn"],
["10222021", "popcorn"],
["10212021", "soda"],
["10212021", "popcorn"],
["10212021", "soda"]]
Output: 26.0
This is a scenario question designed by Shopify itself. It does not correspond to the standard LeetCode. It tests the reading + simulation ability.
Problem-solving ideas:
Group by date, count the quantity of each product per day, then pair and bundle as many as possible, and calculate the rest according to the unit price.
From collections import defaultdict
def calculate_total(orders):
daily = defaultdict(lambda: defaultdict(int))
for date, item in orders:
daily[date][item] += 1
total = 0.0
for date, items in daily.items():
popcorn_count = items.get("popcorn", 0)
soda_count = items.get("soda", 0)
bundles = min(popcorn_count, soda_count)
total += bundles * 9
total += (popcorn_count - bundles) * 8
total += (soda_count - bundles) * 2.5
return total
Real question 4: Sort object array by two attributes
Topic:
Sort an array of objects based on two attributes. Press first
CountryAscending order,CountryPress again when the sameNameAscending order.
Input:
[{"name": "Charlie", "country": "US"},
{"name": "Alice", "country": "CA"},
{"name": "Bob", "country": "US"},
{"name": "Diana", "country": "CA"}]
Output:
[{"name": "Alice", "country": "CA"},
{"name": "Diana", "country": "CA"},
{"name": "Bob", "country": "US"},
{"name": "Charlie", "country": "US"}]
Problem-solving ideas:
The question itself is not difficult. Shopify tests code cleanliness and scalability. Three writing methods from simple to engineering:
Basic writing:
Def sort_people(people):
return sorted(people, key=lambda x: (x["country"], x["name"]))
Encapsulate sort keys for easy maintenance:
Def get_sort_key(person):
return (person["country"], person["name"])
def sort_people(people):
return sorted(people, key=get_sort_key)
Support dynamic fields (bonus points for interviews):
Def sort_by_fields(data, fields):
return sorted(data, key=lambda x: tuple(x[f] for f in fields))
# call
result = sort_by_fields(people, ["country", "name"])
The interviewer asked if descending order should be supported:
Def sort_by_fields_with_order(data, sort_config):
# sort_config: [("country", "asc"), ("name", "desc")]
def make_key(item):
key = []
for field, order in sort_config:
val = item[field]
if order == "desc":
val = [-ord(c) for c in val]
key.append(val)
return key
return sorted(data, key=make_key)
Pitfalls:
- First ask: Is it case sensitive?
"US"And"us"Does it count as the same country? - Shopify cares about readability. Write variable names clearly and don’t use single letters.
- If you take the initiative to propose expansion plans and demonstrate engineering thinking, the interviewer will get extra points.
SQL part
Real question 5: Average order revenue by region
Topic:
Given two tables, find the average order revenue for each region in 2024, returning only regions that are above the overall average.
Orders(order_id, customer_id, order_date, revenue)
customers(customer_id, region)
Solution:
WITH region_avg AS (
SELECT c.region,
AVG(o.revenue) AS avg_rev
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
WHERE EXTRACT(YEAR FROM o.order_date) = 2024
GROUP BY c.region
)
SELECT region, avg_rev
FROM region_avg
WHERE avg_rev > (SELECT AVG(avg_rev) FROM region_avg);
Real question 6: Average monthly ratings of each product
Topic:
Given
Reviews(review_id, user_id, submit_date, product_id, stars)Table, calculating the average monthly rating for each product.
Solution:
SELECT
product_id,
EXTRACT(MONTH FROM submit_date) AS month,
AVG(stars) AS avg_stars
FROM reviews
GROUP BY product_id, EXTRACT(MONTH FROM submit_date)
ORDER BY month, product_id;
Pitfalls:
GROUP BYInsideEXTRACT(MONTH FROM submit_date)Write it out completely, don’t just write the alias- If the question requires distinguishing between years, it should be done at the same time
EXTRACTYear and month, don’t forget the year
Follow-up & experience sharing
There were only three days, so I definitely wouldn’t have time to prepare the system myself, so I thought about it and went directly to ProgramHelp The team helped me write the OA, and I got an AC on both questions, and I successfully entered the next round.
The whole process was smooth. I didn’t have to worry about it after sending the questions to them. They would handle all test cases, including hidden tests. I just have to wait for the results. The team includes people from major first-tier manufacturers such as Amazon, Google, and Alibaba. The code quality and accuracy are guaranteed, and we are not the kind of people who can just find someone to fool them. If you also encounter situations where you are short of time or are really unsure about the topic,OA ghostwriting Is an option. Also, they also do resume packaging, interview coaching, VO assistance, etc.