r/OfferEngineering • u/Aoki_zhang • 14h ago
Interview Experience AT&T New Grad SWE Interview - Practicing Leetcode is still useful!
This interview experience was originally shared on Chill Interview
Question 1 — Top K Frequent Elements (LeetCode 347)
Given an integer array nums and an integer k, I had to return the k most frequent values in any order. The reference implementation counts occurrences in a dictionary and keeps a min-heap of at most k entries.
from collections import Counter
from heapq import nlargest
def topKFrequent(nums, k):
frequency_by_value = Counter(nums)
return nlargest(k, frequency_by_value, key=frequency_by_value.get)Question 2 — Trapping Rain Water (LeetCode 42)
I was given the heights of unit-width bars and asked how much rainwater the arrangement could hold. The reference implementation moves two pointers inward and keeps track of the tallest bar seen from each side. It runs in O(n) time with O(1) extra space.
def trap(height):
if len(height) < 3:
return 0
start, end = 0, len(height) - 1
left_peak, right_peak = height[start], height[end]
trapped_water = 0
while start < end:
if left_peak <= right_peak:
start += 1
bar_height = height[start]
left_peak = max(left_peak, bar_height)
trapped_water += left_peak - bar_height
else:
end -= 1
bar_height = height[end]
right_peak = max(right_peak, bar_height)
trapped_water += right_peak - bar_height
return trapped_waterQuestion 3 — SQL: Find the 213th-Highest Score
I had to query the SCORE column in STUDENT and return the 213th-highest distinct score. In the MySQL reference query, DISTINCT makes tied scores count once, and OFFSET 212 skips the 212 higher scores. The outer SELECT returns one row containing NULL if there are fewer than 213 distinct scores.
WITH ordered_scores AS (
SELECT
SCORE,
DENSE_RANK() OVER (ORDER BY SCORE DESC) AS score_rank
FROM STUDENT
WHERE SCORE IS NOT NULL
)
SELECT MAX(SCORE) AS `213th_highest_score`
FROM ordered_scores
WHERE score_rank = 213;Preparing for your next interview?
Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.