White RoomNEW
Back to feed
Roblox
Roblox
Interview Verified

Roblox SWE Intern - Count Adjacent Equal Colors

Anonymous SWE · Intern · 1
AskedNov 2025
SolvedSolved
LanguageLua
PostedJul 21, 2026
I interviewed for roblox SWE intern positon back in nov 2025, this is word for word the details for said problem, This question is asked right after solving another similar DSA problem for the,. Imagine a number line containing coordinates [0, length - 1] Initially every coordinate is uncolored. You are given a list of painting operations. Each query has the form [coordinate, color] which colors the specified coordinate with the given color. If the coordinate was previously colored, its old color is overwritten. After every query, determine how many adjacent pairs currently share the same color. A pair contributes to the answer if i and i + 1 are both colored and color[i] == color[i+1] Return an array where the ith element is the number of equal adjacent pairs after processing the ith query. Constraints 1 ≤ length ≤ 10^9 1 ≤ queries.length ≤ 10^5 0 ≤ coordinate < length 1 ≤ color ≤ 10^9 Note: Since length may be extremely large, a solution that explicitly stores the entire number line will not fit within memory limits. Example length = 7 queries = [ [1,2], [0,2], [3,5], [3,2], [2,2], [6,1], [1,3] ] Output [0,1,1,1,3,3,1] Explanation After [1,2]: 0 2 0 0 0 0 0 Pairs = 0 After [0,2]: 2 2 0 0 0 0 0 Pairs = 1 After [3,5]: 2 2 0 5 0 0 0 Pairs = 1 After [3,2]: 2 2 0 2 0 0 0 Pairs = 1 After [2,2]: 2 2 2 2 0 0 0 Pairs = 3 After [6,1]: 2 2 2 2 0 0 1 Pairs = 3 After [1,3]: 2 3 2 2 0 0 1 Pairs = 1