Four Classic TikTok OA Questions: Adjacent Character Changes, Closest Earlier Timestamp, Placing Shapes, Fewest Operations to an Arithmetic Sequence
TikTok OA, four approaches: count adjacent differing characters ignoring case, find the closest timestamp before the current time, simulate placing shapes A–E in row-major order, and the fewest +1 operations to turn an array into an arithmetic sequence with difference ±1.
A TikTok OA I took recently. Their questions are very familiar, and you can finish most of them quickly.
T1: Count adjacent differing characters, ignoring case
Count positions where s[i] != s[i + 1] when case is ignored. Scan once, lowercasing each character before comparing.
def count_case_insensitive_changes(s):
t = s.lower()
return sum(1 for x, y in zip(t, t[1:]) if x != y)
T2: The closest timestamp before the current time
Given the current time cur and timestamps sorted in increasing order, find the timestamp closest to cur that is strictly less than cur. Convert the times into numbers (e.g. minutes) as the format requires, and the rest is easy. The list is sorted, so binary search works directly.
from bisect import bisect_left
def to_minutes(t): # "HH:MM" -> minutes
h, m = t.split(":")
return int(h) * 60 + int(m)
def latest_before(cur, stamps):
i = bisect_left([to_minutes(t) for t in stamps], to_minutes(cur)) - 1
return stamps[i] if i >= 0 else None
T3: Placing shapes A–E
You're given five shapes, A through E, and must try to place them in row-major order, then column order, to see whether they fit.
Approach: store each shape's cell offsets in a map (with the top-left cell as (0, 0)). For each placement, loop for x in range(n): for y in range(m): and try each (x, y) as the anchor; the first position where the shape fits is the answer.
T4: Fewest operations to make the difference ±1
Only +1 operations are allowed. What's the minimum number of operations to turn the array into an arithmetic sequence with common difference 1 or −1?
Approach: handle d = 1 and d = −1 separately. The target is start + d·i; since you can only add, you need start + d·i ≥ a[i], i.e. start = max(a[i] − d·i). Compute the starting value for each case, sum the differences, and take the smaller total.
def min_ops_unit_progression(a):
best = None
for d in (1, -1):
start = max((x - d * i for i, x in enumerate(a)), default=0)
ops = sum(start + d * i - x for i, x in enumerate(a))
best = ops if best is None else min(best, ops)
return best
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 2027 CodeSignal OA: Even Digit Count, Cyclic-Shift Difference Sums, Bouncing Diagonals, Most Points in a RangeTikTok · 2026-10-03›
- 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›