TikTok 2027 CodeSignal OA: Even Digit Count, Cyclic-Shift Difference Sums, Bouncing Diagonals, Most Points in a Range
TikTok 2027 CodeSignal OA from the new question bank, four approaches: check whether a number has an even digit count, sums of absolute differences under cyclic shifts, simulating a bouncing diagonal, and choosing a center that covers the most points within 2*lim (sliding window).
It felt a bit harder than last year, and the question bank is new. Here are my approaches.
Q1: Does the number have an even number of digits?
Convert it to a string and check whether the length is divisible by 2.
def has_even_digits(x):
return len(str(abs(x))) % 2 == 0
Q2: Sums of absolute differences after cyclic shifts
Two nested loops: for each shift, compute the sum of absolute differences between aligned positions, collect all the sums, sort them and return. Time O(n²).
def shifted_abs_diff_sums(a, b):
n = len(a)
sums = [sum(abs(a[i] - b[(i + s) % n]) for i in range(n)) for s in range(n)]
return sorted(sums)
Q3: Walk a diagonal, bouncing off walls
Simulate walking along the diagonal and bounce when you hit a wall. Track visited cells in a set so you don't revisit them. Stop at a corner or at an already visited cell, and sum the values along the way.
Q4: Pick a center that covers the most points
Choose a center c and count how many points fall within [c − lim, c + lim]; maximize that count.
It's really asking how many points an interval of length at most 2·lim can cover: sort, then sweep with a sliding window, tracking the maximum count and its center.
def best_center(points, lim):
"""Returns (max number of points, one valid center)"""
pts = sorted(points)
best, center, left = 0, None, 0
for right, x in enumerate(pts):
while x - pts[left] > 2 * lim:
left += 1
if right - left + 1 > best:
best, center = right - left + 1, pts[left] + lim
return best, center
Time O(n log n).
Found this helpful? Let's talk.
Happy to swap interview notes, do mock interviews, or share referral info.

Scan to add me on WeChat
More TikTok notes
View all ›- TikTok Data Engineer Interview | TikTok New Grad, Full ProcessTikTok · 2026-10-04›
- TikTok Data Science OA, 4 Questions Done in 28 Minutes: Metrics, Table Merges, Feature Preprocessing, Random Forest Threshold TuningTikTok · 2026-10-03›
- TikTok OA, All 4 Passed: Min in a Range, Sorting by Vowel Gap, Bouncing Diagonals, Subarrays with at Least k Fruit PairsTikTok · 2026-10-03›
- Four Classic TikTok OA Questions: Adjacent Character Changes, Closest Earlier Timestamp, Placing Shapes, Fewest Operations to an Arithmetic SequenceTikTok · 2026-10-03›