Tesla Interview Questions
Execution order : 1. FROM employees — scan table 2. GROUP BY department — aggregate 3. HAVING COUNT( ) = 10 — filter groups (not rows — use HAVING, not...
Write SQL to select the top 3 departments with at least 10 employees and highest average salary.
Execution order : 1. FROM employees — scan table 2. GROUP BY department — aggregate 3. HAVING COUNT( ) = 10 — filter groups (not rows — use HAVING, not WHERE) 4. ORDER BY avg salary DESC — sort 5. LIMIT 3 — top 3
How would you find the first-touch attribution channel for each user signup?
Why ROW NUMBER over MIN : MIN(event ts) gives you the earliest time but not the channel. ROW NUMBER lets you pick the entire row — channel + timestamp together.
Write SQL to calculate total charging time per Tesla station and compare with the previous day.
Write SQL to identify parts that have been started but not finished in the assembly line.
Note : NOT IN with a subquery fails silently when the subquery contains NULLs — the LEFT JOIN pattern is safer.
Write Python code to return all bigrams from a sentence.
A bigram is a pair of consecutive words. Extension — n grams :
How do you find the top N frequent words from a text block?
At scale (large corpus in Spark):
Explain merge sort, quicksort, and heap sort.
Merge Sort Quicksort Heap Sort Time (avg) O(n log n) O(n log n) O(n log n) Time (worst) O(n log n) O(n²) with bad pivot O(n log n) Space O(n) O(log n) stack O(1) Stable Yes No No Cache Good (sequential) Best (in place) Poor (random access) Merge sort : divide array in half recursively → merge sorted halves. Best for linked lists and external sorting (data that doesn't fit in RAM). Quicksort : pick a pivot → partition so left < pivot < right → recurse. Fastest in practice for in memory data (cach
How would you design a system to find the shortest path between two Tesla Superchargers?
Model as a graph : Nodes : Supercharger stations (lat, lng, charger count, max kw) Edges : routes between stations; weight = driving time or distance Algorithm : Dijkstra's (shortest path, non negative weights) or A (faster with geographic heuristic — Euclidean distance to destination). Data model : Constraints : Max range per charge (e.g., 400 km) — edge is only valid if distance ≤ vehicle range Charger availability — prefer stations with available stalls Battery level — factor in energy cost p