Candidate telemetry diagnostic, error autopsy, and step-by-step query construction walkthrough.
Live aggregated metrics across candidate sandbox attempts
36 solved
First attempt fail
Evaluated submissions
Median time to solve
Unlocked answer
Given a sentence, count word frequencies and return the 5 most common as a list of (word, count) tuples ordered by count descending (ties broken by word ascending).
Words are case-insensitive (treat 'The' and 'the' as the same). Strip punctuation: only keep alphanumeric characters and apostrophes.
result should be a list[tuple[str, int]] of length 5.
Operating on a DataFrame slice without `.copy()`, producing `SettingWithCopyWarning`, or using `.apply(axis=1)` with custom Python functions when vectorized NumPy / pandas column operations could run 50x faster with 0 memory overhead.
Interviewers assess whether you write idiomatic, vectorized pandas code instead of slow row-by-row procedural Python loops.
Construct the solution logically from first principles to avoid typical edge case pitfalls.
Use boolean masks with `.loc[row_mask, col_list]` to avoid chained assignment warnings.
subset = df.loc[df['status'] == 'completed'].copy()
Use numpy/pandas native operations like `.groupby()`, `.transform()`, or column arithmetic.
df['rev_share'] = df['revenue'] / df.groupby('country')['revenue'].transform('sum')Sort values and reset index to match the required evaluation output contract.
result = df.sort_values('rev_share', ascending=False).reset_index(drop=True)import re
from collections import Counter
sentence = (
"The quick brown fox jumps over the lazy dog. "
"The dog was not amused, but the fox was quick to apologize. "
"Quick thinking saved the fox; the dog forgave the fox in the end."
)
words = re.findall(r"[a-zA-Z']+", sentence.lower())
counts = Counter(words)
result = sorted(counts.items(), key=lambda x: (-x[1], x[0]))[:5]
Real code patterns candidates submit that fail the grading suite.
results = []
for i, row in df.iterrows():
results.append(row['val'] * 2)Three recurring syntax and semantic traps relevant to this problem domain.
Modifying a filtered slice like df[df.age > 30]['salary'] = 5000 modifies an ephemeral copy instead of the underlying dataframe.
df[df['active'] == True]['status'] = 'verified' # ❌ SettingWithCopyWarning
df.loc[df['active'] == True, 'status'] = 'verified' # ✅ Idiomatic inplace assignment
Calling df.groupby('category').agg(...) places 'category' into the MultiIndex/Index, making subsequent column references fail.
res = df.groupby('dept')['salary'].mean(); print(res['dept']) # ❌ KeyErrorres = df.groupby('dept', as_index=False)['salary'].mean() # ✅ Keeps column intactIterating rows with for index, row in df.iterrows() is an anti-pattern in data science interviews.
for i, r in df.iterrows(): df.at[i, 'total'] = r['price'] * r['qty'] # ❌ Slow
df['total'] = df['price'] * df['qty'] # ✅ C-speed vectorization
Launch our in-browser coding environment. Run queries, view execution plans, and get instant comparative diff grading with no setup.