50 FAANG Interview Questions in English + Model Answers
Preparing for FAANG (Facebook/Meta, Amazon, Apple, Netflix, Google) interviews? These companies test a mix of technical skills (coding, algorithms, system design), behavioral traits (leadership, culture fit), and domain knowledge (e.g., ML for certain roles).
Category 1: Coding & Algorithms (1–20)
1. Two Sum (LeetCode Easy)
Q: Given an array of integers nums and an integer target, return indices of two numbers that add up to target.
Model Answer (Python, O(n) time):
def twoSum(nums, target):
seen = {}
for i, num in enumerate(nums):
complement = target - num
if complement in seen:
return [seen[complement], i]
seen[num] = i
Explanation: Use a hash map to store seen numbers. One pass → O(n) time, O(n) space.
2. Longest Substring Without Repeating Characters
Q: Find length of longest substring without repeating chars.
Model Answer (Sliding Window):
def lengthOfLongestSubstring(s):
char_set = set()
left = res = 0
for right in range(len(s)):
while s[right] in char_set:
char_set.remove(s[left])
left += 1
char_set.add(s[right])
res = max(res, right - left + 1)
return res
O(n) time, O(min(m, n)) space where m = alphabet size.
3. Merge k Sorted Lists
Q: Merge k sorted linked lists into one.
Model Answer (Min-Heap):
import heapq
def mergeKLists(lists):
heap = [(node.val, i, node) for i, node in enumerate(lists) if node]
heapq.heapify(heap)
dummy = cur = ListNode()
while heap:
val, list_idx, node = heapq.heappop(heap)
cur.next = node
cur = cur.next
if node.next:
heapq.heappush(heap, (node.next.val, list_idx, node.next))
return dummy.next
O(N log k) where N = total nodes.
4. Valid Parentheses
Model Answer (Stack):
def isValid(s):
stack = []
pairs = {')': '(', '}': '{', ']': '['}
for c in s:
if c in pairs:
if not stack or stack.pop() != pairs[c]:
return False
else:
stack.append(c)
return not stack
5. LRU Cache
Q: Design LRU Cache with get and put in O(1).
Model Answer (HashMap + Doubly Linked List):
class ListNode:
def __init__(self, key=0, val=0):
self.key, self.val = key, val
self.prev = self.next = None
class LRUCache:
def __init__(self, capacity):
self.cap = capacity
self.cache = {}
self.left, self.right = ListNode(), ListNode()
self.left.next, self.right.prev = self.right, self.left
def _remove(self, node):
prev, nxt = node.prev, node.next
prev.next, nxt.prev = nxt, prev
def _insert(self, node):
prev = self.right.prev
prev.next = node
self.right.prev = node
node.prev, node.next = prev, self.right
def get(self, key):
if key in self.cache:
self._remove(self.cache[key])
self._insert(self.cache[key])
return self.cache[key].val
return -1
def put(self, key, value):
if key in self.cache:
self._remove(self.cache[key])
self.cache[key] = ListNode(key, value)
self._insert(self.cache[key])
if len(self.cache) > self.cap:
lru = self.left.next
self._remove(lru)
del self.cache[lru.key]
6–20: Quick Model Answers (Common Patterns)
| # | Question | Key Idea | Time/Space |
|---|---|---|---|
| 6 | Trapping Rain Water | Two pointers | O(n)/O(1) |
| 7 | Word Ladder | BFS | O(N×L) |
| 8 | Course Schedule | Topological Sort (Kahn’s) | O(V+E) |
| 9 | Clone Graph | DFS + HashMap | O(V+E) |
| 10 | Number of Islands | DFS/BFS | O(m×n) |
| 11 | Rotate Image | Transpose + Reverse | O(n²) |
| 12 | Serialize/Deserialize BST | Preorder DFS | O(n) |
| 13 | Longest Increasing Subsequence | DP + Binary Search | O(n log n) |
| 14 | Median of Two Sorted Arrays | Binary Search | O(log(m+n)) |
| 15 | Regular Expression Matching | DP | O(m×n) |
| 16 | Merge Intervals | Sort + Merge | O(n log n) |
| 17 | Kth Largest Element | Quickselect / Heap | O(n) avg |
| 18 | Find Median from Data Stream | Two Heaps | O(log n) |
| 19 | Text Justification | Greedy | O(n) |
| 20 | Minimum Window Substring | Sliding Window + Counter | O(n) |
(Full code available in PDF)
Category 2: System Design (21–30)
21. Design TinyURL
Model Answer:
- API:
POST /shorten→ returns short code;GET /{code}→ 301 redirect. - Short code: Base62 encode auto-increment ID or hash(longURL).
- DB:
(id, long_url, expiry). Use NoSQL for scale. - Cache: Redis for hot URLs.
- Edge: Handle collisions with retry; rate limiting.
22. Design Twitter Timeline
Components:
- Write API → Fanout to followers’ Redis lists (push model for <1K followers).
- Read API → Merge K sorted lists (heap) from followed users + self.
- Cache: Redis sorted sets per user.
- Scale: Sharding by
user_id.
23. Design Uber Backend
Key Features:
- Location Service: Quadtree / Geohash indexing.
- Matching: Nearest driver → ETA via Google Maps API.
- ETA Calc: Graph (Dijkstra) + ML traffic model.
- DB: Drivers → Cassandra (location updates); Rides → PostgreSQL.
24–30: Concise Answers
| # | System | Core Idea |
|---|---|---|
| 24 | Netflix Recommendation | Collaborative + Content-based filtering |
| 25 | Erlang + Mnesia, WebSocket, E2E encryption | |
| 26 | Instagram Feed | Fanout-on-write + Rank by engagement ML |
| 27 | Rate Limiter | Token Bucket / Leaky Bucket (Redis) |
| 28 | Distributed Cache | Consistent Hashing + Replication |
| 29 | API Gateway | Auth, Rate Limit, Routing (Kong/Envoy) |
| 30 | Message Queue | Kafka partitions + Consumer groups |
Category 3: Behavioral & Leadership (31–40)
31. Tell me about a time you failed.
STAR Answer:
- S: Led a microservice migration.
- T: Deliver in 2 sprints.
- A: Underestimated DB schema conflicts; launched with bugs.
- R: Rolled back in 15 min, added schema validation → 100% success next sprint. Learned: Fail-fast with feature flags.
32. Disagree and Commit?
Answer: “At Amazon, I pushed for Go over Java for a low-latency service. Data showed only 5% gain. Leadership chose Java for ecosystem. I disagreed but committed—delivered 20% faster via caching. Principle respected.”
33–40: Model One-Liners
- Conflict with peer → “Used data in 1:1; aligned on A/B test.”
- Tight deadline → “Prioritized MVP; automated tests → shipped on time.”
- Mentored junior → “Pair-programmed; they led next feature.”
- Handled ambiguous req → “Clarified with PM via mocks; reduced rework 40%.”
- Dealt with legacy code → “Refactored incrementally with 95% test coverage.”
- Customer obsession → “Added analytics; reduced churn 12%.”
- Bias for action → “Launched beta in 48h; iterated on feedback.”
- Invent & Simplify → “Replaced 5 tools with one internal library.”
Category 4: OS, Networks, DB (41–50)
41. Virtual Memory
Answer: Paging + segmentation. Page table maps virtual → physical. TLB caches recent translations. Thrashing → increase RAM or reduce working set.
42. TCP vs UDP
| TCP | UDP |
|---|---|
| Reliable, ordered | Best-effort |
| Handshake, flow control | No overhead |
| HTTP, Email | DNS, Video |
43. CAP Theorem
Answer: In distributed systems, only two of Consistency, Availability, Partition tolerance. Example: Cassandra (AP), MongoDB strong consistency mode (CP).
44. SQL: Find 2nd Highest Salary
SELECT MAX(salary) FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
45. Index Types
- B-Tree: Range scans (default).
- Hash: Equality.
- Bitmap: Low-cardinality columns.
46–50: Quick Facts
- Deadlock Prevention: Avoid circular wait (resource ordering).
- Load Balancer Algorithms: Round-robin, Least connections.
- OAuth 2.0 Flow: Authorization code → access token → API call.
- Consistency Models: Eventual (DynamoDB) vs Strong (Spanner).
- Microservices Anti-pattern: Distributed monolith (tight coupling).
Free PDF Download Script
# save_as_pdf.py
from fpdf import FPDF
import textwrap
questions = [
("1. Two Sum", "Given nums and target...", "```python\ndef twoSum(nums, target): ...```"),
# Add all 50 Q&A here (copy from above)
]
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, txt="50 FAANG Interview Q&A", ln=1, align='C')
for i, (q, ques, ans) in enumerate(questions, 1):
pdf.set_font("Arial", 'B', 12)
pdf.multi_cell(0, 10, f"{i}. {q}")
pdf.set_font("Arial", size=10)
wrapped = textwrap.fill(ques, width=90)
pdf.multi_cell(0, 8, wrapped)
pdf.multi_cell(0, 8, ans)
pdf.ln(5)
pdf.output("FAANG_50_Questions.pdf")
print("PDF generated: FAANG_50_Questions.pdf")
How to Use:
- Copy all 50 Q&A into
questionslist. - Run
python save_as_pdf.py. - Get
FAANG_50_Questions.pdfinstantly!

0 Comments