Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 1–7 of 7

Popular tracks

Senior Detailed
How do you find Longest Increasing Subsequence (LIS)?

Short answer: Classic DP is O(n²): dp[i] = best LIS ending at i. The optimized patience-sorting / binary-search approach maintains tails of increasing subsequences in O(n log n). Mention both; implement O(n²) unless aske…

Dynamic Programming Read answer
Senior Detailed
How would you design an LRU Cache?

Short answer: Hash map from key → node plus a doubly linked list ordered by recency. get/put are O(1): move accessed node to front; on capacity eviction remove from tail. This is one of the most asked system-design-lite…

Design Read answer
Senior
How do you serialize and deserialize a binary tree?

Short answer: Use preorder with null markers (e.g. "#") or level-order BFS with nulls. Deserialization consumes the same format with a queue/iterator. Clarify the string format with the interviewer first. Complexity Time…

Trees Read answer
Senior
Explain Trapping Rain Water at a high level.

Short answer: Water at i is min(leftMax, rightMax) − height[i]. Compute with two arrays, or optimize with two pointers moving from ends while tracking leftMax/rightMax. Stack-based solution processes bars as histogram va…

Two Pointers / Stack Read answer
Senior
How do you solve Sliding Window Maximum?

Short answer: Monotonic deque storing indices in decreasing height order. As the window slides, pop out-of-window indices from front and smaller values from back. Front is always the max. O(n). Complexity Time O(n), Spac…

Deque / Sliding Window Read answer
Senior
How do you approach Word Ladder (shortest transformation)?

Short answer: Model words as graph nodes; edges connect words differing by one letter. BFS from beginWord finds shortest transformation length. Bidirectional BFS is a strong optimization follow-up. Complexity Time roughl…

Graphs / BFS Read answer
Senior
Explain Longest Common Subsequence (LCS) for interviews.

Short answer: 2-D DP: if s[i]==t[j], dp[i][j] = dp[i-1][j-1]+1 else max(skip either char). Classic O(m*n) table; can compress to two rows for space. Common follow-ups Print the LCS string Longest Common Substring (differ…

Dynamic Programming Read answer

DSA & Coding Interviews Coding Interview FAQ · Dynamic Programming

Short answer: Classic DP is O(n²): dp[i] = best LIS ending at i. The optimized patience-sorting / binary-search approach maintains tails of increasing subsequences in O(n log n). Mention both; implement O(n²) unless asked for optimal.

Complexity

DP O(n²); patience sorting O(n log n).

Common follow-ups

  • Print one LIS
  • Longest decreasing / bitonic subsequence
Interviewers love hearing both complexities even if you code the simpler DP.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Design

Short answer: Hash map from key → node plus a doubly linked list ordered by recency. get/put are O(1): move accessed node to front; on capacity eviction remove from tail. This is one of the most asked system-design-lite coding questions.

Interview approach

  1. Clarify capacity and that both get and put must be O(1).
  2. Explain why list alone or map alone is not enough.
  3. Implement move-to-front and remove-tail helpers.
  4. Handle update of existing key in put.

Complexity

get/put O(1) average; Space O(capacity).

Common follow-ups

  • LFU Cache
  • Thread-safe LRU
  • TTL expiration

Mistakes to avoid

  • Forgetting to update value on put for existing key
  • Losing list pointers when removing
In C#, LinkedList + Dictionary is the standard interview implementation.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Trees

Short answer: Use preorder with null markers (e.g. "#") or level-order BFS with nulls. Deserialization consumes the same format with a queue/iterator. Clarify the string format with the interviewer first.

Complexity

Time O(n), Space O(n).

Pick one format and stick to it — inconsistency is a common fail point.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Two Pointers / Stack

Short answer: Water at i is min(leftMax, rightMax) − height[i]. Compute with two arrays, or optimize with two pointers moving from ends while tracking leftMax/rightMax. Stack-based solution processes bars as histogram valleys.

Complexity

Two pointers O(n) time, O(1) space.

Relate it to Container With Most Water but stress per-index water units.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Deque / Sliding Window

Short answer: Monotonic deque storing indices in decreasing height order. As the window slides, pop out-of-window indices from front and smaller values from back. Front is always the max. O(n).

Complexity

Time O(n), Space O(k).

This is a classic “monotonic queue” question — name the pattern.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Graphs / BFS

Short answer: Model words as graph nodes; edges connect words differing by one letter. BFS from beginWord finds shortest transformation length. Bidirectional BFS is a strong optimization follow-up.

Complexity

Time roughly O(N * L * 26) with wildcards or neighbor generation.

BFS = shortest path in unweighted graph — say that sentence.
Permalink & share

DSA & Coding Interviews Coding Interview FAQ · Dynamic Programming

Short answer: 2-D DP: if s[i]==t[j], dp[i][j] = dp[i-1][j-1]+1 else max(skip either char). Classic O(m*n) table; can compress to two rows for space.

Common follow-ups

  • Print the LCS string
  • Longest Common Substring (different recurrence)
  • Edit Distance
Contrast subsequence (not contiguous) vs substring (contiguous) immediately.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details