Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Yes, C# 8 introduced private methods in interfaces. Explain a bit more Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string messa…
Short answer: Abstract classes often define base contracts or template methods for patterns: Abstract Factory: Defines abstract methods to create families of objects. Strategy Pattern: Abstract class defines a common int…
Short answer: Encapsulation and abstraction hide implementation details, exposing only necessary interfaces. Polymorphism allows replaceable modules, facilitating microservices independently deployed and evolved. SOLID p…
Short answer: Kadane’s algorithm: keep a running sum; if it goes negative, reset to 0 (or start fresh at the next element). Track the best running sum seen. This finds the contiguous subarray with maximum sum in O(n). Pr…
Short answer: Build prefix products from the left and suffix products from the right. For index i, answer[i] = prefix[i] * suffix[i]. You can do it with one output array and one running suffix to achieve O(1) extra space…
Short answer: Sort the array. Fix one number, then use two pointers on the remainder to find pairs that sum to −fixed. Skip duplicates carefully to return unique triplets. Overall O(n²). Interview approach Sort ascending…
Short answer: Two pointers at both ends. Area = min(height[L], height[R]) * (R − L). Move the pointer at the shorter line inward, because width shrinks and only a taller line can improve area. O(n) time. Complexity Time…
Short answer: Sliding window with a map/set of characters in the current window. Expand right; when a duplicate appears, shrink left until the window is unique again. Track max window length. Sample solution C# int Lengt…
Short answer: Each node must lie within an allowed (low, high) range. Recurse left with high = node.val and right with low = node.val. Alternatively, inorder traversal must produce a strictly increasing sequence. Complex…
Short answer: Scan the grid. When you find a '1', increment island count and DFS/BFS to sink (mark visited) the entire connected land component. Count how many times you start a flood fill. Complexity Time O(rows * cols)…
Short answer: Model prerequisites as a directed graph. Detect a cycle with DFS colors (white/gray/black) or Kahn’s algorithm (BFS indegrees). If a cycle exists, you cannot finish all courses. Complexity Time O(V + E), Sp…
Short answer: Unbounded knapsack DP: dp[a] = minimum coins to make amount a. For each coin, update dp[x] = min(dp[x], dp[x - coin] + 1). Initialize dp[0] = 0 and others to +∞. Return -1 if unreachable. Complexity Time O(…
Short answer: Sort intervals by start. Scan and merge when the next start ≤ current end; otherwise push current and start a new one. O(n log n) from sorting. Sample solution C# int[][] Merge(int[][] intervals) { Array.So…
Short answer: Modified binary search: check which half is sorted, then decide whether the target lies in that sorted half. Still O(log n). Interview approach Compute mid. If left half sorted (nums[lo] ≤ nums[mid]): if ta…
Short answer: DFS from each cell matching the first letter. Mark visited, explore 4 directions for the next character, then unmark (backtrack). Return true as soon as the word is completed. Complexity Time roughly O(N *…
Short answer: Each node has children map/array[26] and an isEnd flag. insert/search/startsWith walk character by character. Tries shine for autocomplete and dictionary prefix queries. Complexity Time O(L) per operation (…
Short answer: A Tech Lead balances architecture quality, delivery predictability, and team growth. You need strong technical depth plus execution leadership under constraints. Show that you can make decisions, align stak…
Short answer: Engineering Managers are accountable for team performance, people growth, and delivery health. This shift requires moving from individual output to systems of execution and coaching. You still need technica…
Short answer: Career communication improves through structured thinking, concise speaking, and intentional listening. Strong communicators reduce confusion, unblock teams faster, and build trust across levels. Treat comm…
Short answer: Two pointers with a gap of n. Advance fast n steps, then move both until fast hits the end; slow.next is the node to delete. One pass, O(1) space. Edge cases to mention Remove head (n == length) Single node…
Short answer: BFS with a queue. Process level size at a time, enqueue children, and collect values per level into a list of lists. Complexity Time O(n), Space O(n) for the queue/result. Common follow-ups Zigzag level ord…
Short answer: BST: walk from root — if both values are smaller go left, both larger go right, else current is LCA. General binary tree: recurse; if both sides return non-null, current is LCA; else return the non-null sid…
Short answer: Count frequencies with a hash map. Then either use a min-heap of size k (O(n log k)) or bucket sort by frequency (O(n)) since frequencies are in 1..n. Complexity Heap O(n log k); bucket O(n). Common follow-…
Short answer: BFS/DFS while maintaining a map from original node → clone. For each neighbor, clone if missing, then link clones. Prevents infinite loops on cycles. Complexity Time O(V + E), Space O(V). The visited/clone…
Short answer: Min-heap of size k: O(n log k). Quickselect (partition) average O(n), worst O(n²). Sorting is O(n log n) — mention then improve. Common follow-ups Kth largest in a stream Find median If they care about wors…
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, C# 8 introduced private methods in interfaces.
Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) => LogInternal(message); private void LogInternal(string msg) => Console.WriteLine(msg); } Yes, C# 8 introduced private methods in interfaces. Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) => LogInternal(message); private void LogInternal(string msg) => Console.WriteLine(msg);
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
C# OOP C# Programming Tutorial · OOP
Short answer: Abstract classes often define base contracts or template methods for patterns: Abstract Factory: Defines abstract methods to create families of objects. Strategy Pattern: Abstract class defines a common interface for interchangeable algorithms. abstract class PaymentStrategy {
public abstract void Pay(decimal amount);
}
class CreditCardPayment : PaymentStrategy
{
public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount} by credit card"); }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Encapsulation and abstraction hide implementation details, exposing only necessary interfaces. Polymorphism allows replaceable modules, facilitating microservices independently deployed and evolved. SOLID principles and interface-based contracts promote loose coupling and autonomous service design.
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
DSA & Coding Interviews Coding Interview FAQ · Arrays & DP
Short answer: Kadane’s algorithm: keep a running sum; if it goes negative, reset to 0 (or start fresh at the next element). Track the best running sum seen. This finds the contiguous subarray with maximum sum in O(n).
Given an integer array, find the contiguous subarray with the largest sum and return that sum.
int MaxSubArray(int[] nums) {
int best = nums[0], cur = nums[0];
for (int i = 1; i < nums.Length; i++) {
cur = Math.Max(nums[i], cur + nums[i]);
best = Math.Max(best, cur);
}
return best;
}
Time O(n), Space O(1).
If the interviewer allows empty subarray, resetting to 0 is fine; otherwise use the version above.
DSA & Coding Interviews Coding Interview FAQ · Arrays & Prefix
Short answer: Build prefix products from the left and suffix products from the right. For index i, answer[i] = prefix[i] * suffix[i]. You can do it with one output array and one running suffix to achieve O(1) extra space (excluding output).
int[] ProductExceptSelf(int[] nums) {
int n = nums.Length;
var ans = new int[n];
ans[0] = 1;
for (int i = 1; i < n; i++) ans[i] = ans[i - 1] * nums[i - 1];
int right = 1;
for (int i = n - 1; i >= 0; i--) {
ans[i] *= right;
right *= nums[i];
}
return ans;
}
Time O(n), Space O(1) extra (output not counted).
Never use division in the interview version — many panels explicitly forbid it.
DSA & Coding Interviews Coding Interview FAQ · Two Pointers
Short answer: Sort the array. Fix one number, then use two pointers on the remainder to find pairs that sum to −fixed. Skip duplicates carefully to return unique triplets. Overall O(n²).
Time O(n²), Space O(1) extra besides output (sorting may use O(log n)).
Sorting + two pointers is the pattern interviewers expect after Two Sum.
DSA & Coding Interviews Coding Interview FAQ · Two Pointers
Short answer: Two pointers at both ends. Area = min(height[L], height[R]) * (R − L). Move the pointer at the shorter line inward, because width shrinks and only a taller line can improve area. O(n) time.
Time O(n), Space O(1).
Prove the greedy move: the shorter side is the bottleneck.
DSA & Coding Interviews Coding Interview FAQ · Sliding Window
Short answer: Sliding window with a map/set of characters in the current window. Expand right; when a duplicate appears, shrink left until the window is unique again. Track max window length.
int LengthOfLongestSubstring(string s) {
var last = new Dictionary<char, int>();
int left = 0, best = 0;
for (int right = 0; right < s.Length; right++) {
char c = s[right];
if (last.TryGetValue(c, out int prev) && prev >= left)
left = prev + 1;
last[c] = right;
best = Math.Max(best, right - left + 1);
}
return best;
}
Time O(n), Space O(min(n, alphabet)).
Name the pattern “variable-size sliding window” — it signals seniority.
DSA & Coding Interviews Coding Interview FAQ · Trees
Short answer: Each node must lie within an allowed (low, high) range. Recurse left with high = node.val and right with low = node.val. Alternatively, inorder traversal must produce a strictly increasing sequence.
Time O(n), Space O(h) recursion height.
Pass long.MinValue/MaxValue (or nullable bounds) to avoid int overflow edge cases.
DSA & Coding Interviews Coding Interview FAQ · Graphs / Grid DFS
Short answer: Scan the grid. When you find a '1', increment island count and DFS/BFS to sink (mark visited) the entire connected land component. Count how many times you start a flood fill.
Time O(rows * cols), Space O(rows * cols) worst-case recursion/queue.
Clarify 4-direction vs 8-direction before coding.
DSA & Coding Interviews Coding Interview FAQ · Graphs
Short answer: Model prerequisites as a directed graph. Detect a cycle with DFS colors (white/gray/black) or Kahn’s algorithm (BFS indegrees). If a cycle exists, you cannot finish all courses.
Time O(V + E), Space O(V + E).
Say “topological sort / cycle detection” early — that is the pattern name they want.
DSA & Coding Interviews Coding Interview FAQ · Dynamic Programming
Short answer: Unbounded knapsack DP: dp[a] = minimum coins to make amount a. For each coin, update dp[x] = min(dp[x], dp[x - coin] + 1). Initialize dp[0] = 0 and others to +∞. Return -1 if unreachable.
Time O(amount * coins), Space O(amount).
Mention top-down memoization as an alternative to bottom-up.
DSA & Coding Interviews Coding Interview FAQ · Intervals
Short answer: Sort intervals by start. Scan and merge when the next start ≤ current end; otherwise push current and start a new one. O(n log n) from sorting.
int[][] Merge(int[][] intervals) {
Array.Sort(intervals, (a, b) => a[0].CompareTo(b[0]));
var res = new List<int[]>();
foreach (var iv in intervals) {
if (res.Count == 0 || res[^1][1] < iv[0]) res.Add(iv);
else res[^1][1] = Math.Max(res[^1][1], iv[1]);
}
return res.ToArray();
}
Time O(n log n), Space O(n).
Sorting by start is non-negotiable — say it before coding.
DSA & Coding Interviews Coding Interview FAQ · Binary Search
Short answer: Modified binary search: check which half is sorted, then decide whether the target lies in that sorted half. Still O(log n).
Time O(log n), Space O(1).
Draw a rotated array and mark the sorted half each step while explaining.
DSA & Coding Interviews Coding Interview FAQ · Backtracking
Short answer: DFS from each cell matching the first letter. Mark visited, explore 4 directions for the next character, then unmark (backtrack). Return true as soon as the word is completed.
Time roughly O(N * 4^L) worst case (N cells, L word length); Space O(L) recursion.
Emphasize marking/unmarking — that is the backtracking signature.
DSA & Coding Interviews Coding Interview FAQ · Tries
Short answer: Each node has children map/array[26] and an isEnd flag. insert/search/startsWith walk character by character. Tries shine for autocomplete and dictionary prefix queries.
Time O(L) per operation (L = word length), Space O(total characters).
Ask if alphabet is lowercase English — array[26] is cleaner than Dictionary.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: A Tech Lead balances architecture quality, delivery predictability, and team growth. You need strong technical depth plus execution leadership under constraints. Show that you can make decisions, align stakeholders, and unblock others consistently.
Ananya at Infosys was a strong coder but had little leadership exposure. Vikram from Freshworks asked her to lead a migration project involving backend, QA, and DevOps teams. She introduced weekly risk tracking and clearer technical decision notes. The project shipped on time and her manager started positioning her as a tech lead candidate.
Tech leads are measured by team outcomes, not personal output alone.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: Engineering Managers are accountable for team performance, people growth, and delivery health. This shift requires moving from individual output to systems of execution and coaching. You still need technical credibility, but your primary lever becomes people and process.
Meera at Freshworks was a senior IC and wanted to move into engineering management. Rohit from CRED suggested she begin by mentoring two engineers and owning sprint health metrics. She improved planning accuracy and reduced release chaos over two quarters. Leadership recognized her readiness and moved her into an EM-track role.
EM growth starts when team success becomes your main KPI.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: Career communication improves through structured thinking, concise speaking, and intentional listening. Strong communicators reduce confusion, unblock teams faster, and build trust across levels. Treat communication as a skill to practice weekly, not a personality trait.
Neha at CRED was technically strong but struggled to communicate updates to leadership. Arjun from Flipkart coached her to use a fixed status format with risks and decisions highlighted. She also practiced concise demos before stakeholder meetings. Her communication confidence improved and she was included in more cross-team discussions.
Clarity is the fastest path to influence.
DSA & Coding Interviews Coding Interview FAQ · Linked Lists
Short answer: Two pointers with a gap of n. Advance fast n steps, then move both until fast hits the end; slow.next is the node to delete. One pass, O(1) space.
Use a dummy head so deleting the real head is uniform.
DSA & Coding Interviews Coding Interview FAQ · Trees
Short answer: BFS with a queue. Process level size at a time, enqueue children, and collect values per level into a list of lists.
Time O(n), Space O(n) for the queue/result.
Capturing level size before the inner loop is the key detail interviewers watch for.
DSA & Coding Interviews Coding Interview FAQ · Trees
Short answer: BST: walk from root — if both values are smaller go left, both larger go right, else current is LCA. General binary tree: recurse; if both sides return non-null, current is LCA; else return the non-null side.
BST average O(h); general tree O(n).
Ask which tree type — the optimal approach changes.
DSA & Coding Interviews Coding Interview FAQ · Heap / Bucket Sort
Short answer: Count frequencies with a hash map. Then either use a min-heap of size k (O(n log k)) or bucket sort by frequency (O(n)) since frequencies are in 1..n.
Heap O(n log k); bucket O(n).
Prefer bucket sort when you want to show O(n) mastery.
DSA & Coding Interviews Coding Interview FAQ · Graphs
Short answer: BFS/DFS while maintaining a map from original node → clone. For each neighbor, clone if missing, then link clones. Prevents infinite loops on cycles.
Time O(V + E), Space O(V).
The visited/clone map is mandatory — say it before writing loops.
DSA & Coding Interviews Coding Interview FAQ · Heap / Quickselect
Short answer: Min-heap of size k: O(n log k). Quickselect (partition) average O(n), worst O(n²). Sorting is O(n log n) — mention then improve.
If they care about worst-case, discuss heap; if average-case, mention Quickselect.