Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: The Singleton pattern ensures a class has only one instance and provides a global point of access to it. It’s commonly used when exactly one object is needed to coordinate actions across the system, such as…
Short answer: The Factory pattern is a creational design pattern that provides an interface for creating objects but allows subclasses or implementations to decide which class to instantiate. Explain a bit more It’s used…
Short answer: The Strategy pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime. It allows the algorithm to vary independently from…
Short answer: Applications? The Repository pattern abstracts the data access layer from the business logic by providing collection-like interface to access domain objects. It helps keep data access logic centralized and…
Short answer: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); } Example code cl…
Short answer: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a…
Short answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a base Payme…
Short answer: Duck typing: "If it looks like a duck and quacks like a duck, it is a duck." Behavior is based on method/property availability, not type inheritance. C# does not support full dynamic duck typing,…
Short answer: Allows interfaces to provide default method implementations. Reason: Enables adding new methods to interfaces without breaking existing implementations. interface IPrinter Example code { void Print(string m…
Short answer: Use a hash map from value → index while scanning once. For each number x, check if target − x is already seen; if yes, return both indices. This is O(n) time and O(n) space — the expected answer after you b…
Short answer: Track the minimum price so far while scanning left to right. At each day, compute profit = price − minSoFar and keep the maximum profit. One pass, O(1) extra space. Problem statement prices[i] is the stock…
Short answer: Insert elements into a HashSet while scanning. If an insert fails (already present), return true. Sorting and comparing neighbors also works in O(n log n) with O(1) extra space if sorting in place is allowe…
Short answer: Valid Anagram: count character frequencies (or sort both strings). Group Anagrams: use a frequency signature or sorted string as dictionary key and bucket words together. Complexity Valid: O(n). Group: O(n…
Short answer: Push opening brackets. On a closing bracket, pop and check it matches. At the end the stack must be empty. Covers (), {}, [] in one pass. Sample solution C# bool IsValid(string s) { var st = new Stack<ch…
Short answer: Iterative: three pointers prev, curr, next. Flip curr.next to prev and advance. Recursive: reverse the rest, then point head.next.next = head and head.next = null. Iterative is usually preferred in intervie…
Short answer: Use a dummy head and append the smaller of the two current nodes until one list is exhausted, then attach the remainder. Recursive merge is elegant but uses stack space. Complexity Time O(n + m), Space O(1)…
Short answer: Climbing Stairs: ways(n) = ways(n-1) + ways(n-2) — Fibonacci DP. House Robber: dp[i] = max(dp[i-1], dp[i-2] + nums[i]) — cannot rob adjacent houses. Both reduce to O(1) space with two rolling variables. Com…
Short answer: Maintain inclusive or exclusive bounds consistently. Compute mid carefully (lo + (hi − lo) / 2) to avoid overflow. Decide whether you want lower-bound, upper-bound, or exact match before coding. Complexity…
Short answer: Clarify inputs/outputs/constraints first. Propose brute force, then optimize. Speak while coding, test with an example, and state complexity. Silence is riskier than imperfect code with clear thinking. Inte…
Short answer: To become a Senior Software Engineer, you must show independent ownership, reliable execution, and better engineering judgment than your current level. Seniority is not about years alone; it is about scope…
Short answer: Solution Architects bridge business needs and technical implementation. You need enough technical depth to design feasible systems and enough communication skill to align non-technical stakeholders. Busines…
Short answer: Faster promotions come from visible impact on high-priority problems, not extra hours alone. If your work consistently reduces risk, saves cost, or accelerates delivery, promotion discussions become easier.…
Short answer: A career growth plan turns vague ambition into measurable actions. It should define your target role, current gap, timeline, and progress checkpoints. Without a plan, growth becomes reactive and slower. Ste…
Short answer: Floyd’s tortoise and hare: slow moves 1, fast moves 2. If they meet, there is a cycle. To find the cycle entrance, reset one pointer to head and move both one step until they meet. Complexity Time O(n), Spa…
Short answer: BFS uses a queue and finds shortest paths in unweighted graphs / level order. DFS uses a stack/recursion and is natural for path existence, cycle detection, topological sort, and flood fill. Pick based on w…
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Singleton pattern ensures a class has only one instance and provides a global point of access to it. It’s commonly used when exactly one object is needed to coordinate actions across the system, such as configuration settings, logging, or caching.
ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Factory pattern is a creational design pattern that provides an interface for creating objects but allows subclasses or implementations to decide which class to instantiate.
It’s used to encapsulate object creation, promoting loose coupling and flexibility when the exact types of objects aren’t known until runtime. Use case: When a class can’t anticipate the class of objects it needs to create, or when you want to delegate responsibility for object creation to subclasses.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Strategy pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime. It allows the algorithm to vary independently from clients that use it. Problem it solves: Avoids large if-else or switch statements when selecting behavior and promotes flexibility by decoupling the algorithm from the client using it.
ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Applications? The Repository pattern abstracts the data access layer from the business logic by providing collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codebase easier to maintain, test, and swap out data sources (e.g., switching from EF Core to Dapper or an API). Say this in the… interview
C# OOP C# Programming Tutorial · OOP
Short answer: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); }
class FileLogger : ILogger { public void Log(string message) => Console.WriteLine("File: " + message); } class UserService
{
private readonly ILogger _logger;
public UserService(ILogger logger) { _logger = logger; }
}
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: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Duck typing: "If it looks like a duck and quacks like a duck, it is a duck." Behavior is based on method/property availability, not type inheritance. C# does not support full dynamic duck typing, but interfaces enable a similar concept by relying on contract-based behavior. Dynamic types in C# (dynamic) can also simulate duck typing. interface IFlyable { void Fly(); }
void MakeItFly(IFlyable obj) => obj.Fly(); // Any object implementing IFlyable works
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: Allows interfaces to provide default method implementations. Reason: Enables adding new methods to interfaces without breaking existing implementations. interface IPrinter
{ void Print(string msg); void PrintInfo(string msg) => Console.WriteLine("Info: " + msg); // Default }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
DSA & Coding Interviews Coding Interview FAQ · Arrays & Hashing
Short answer: Use a hash map from value → index while scanning once. For each number x, check if target − x is already seen; if yes, return both indices. This is O(n) time and O(n) space — the expected answer after you briefly mention the O(n²) nested-loop brute force.
Given an array of integers and a target, return indices of two numbers that add up to the target. Assume exactly one solution and you may not use the same element twice.
Nested loops comparing every pair — correct but too slow for large n.
One pass with Dictionary/HashMap. Lookup is average O(1).
// C#
int[] TwoSum(int[] nums, int target) {
var map = new Dictionary<int, int>();
for (int i = 0; i < nums.Length; i++) {
int need = target - nums[i];
if (map.TryGetValue(need, out int j)) return new[] { j, i };
map[nums[i]] = i;
}
throw new InvalidOperationException("No solution");
}
Time O(n), Space O(n).
Always start with brute force, then optimize — interviewers score communication as much as code.
DSA & Coding Interviews Coding Interview FAQ · Arrays & Greedy
Short answer: Track the minimum price so far while scanning left to right. At each day, compute profit = price − minSoFar and keep the maximum profit. One pass, O(1) extra space.
prices[i] is the stock price on day i. You may buy once and sell once later. Return the maximum profit (0 if no profit).
int MaxProfit(int[] prices) {
int minPrice = int.MaxValue, best = 0;
foreach (int p in prices) {
if (p < minPrice) minPrice = p;
else best = Math.Max(best, p - minPrice);
}
return best;
}
Time O(n), Space O(1).
Say “running minimum” out loud — it shows you understand the greedy invariant.
DSA & Coding Interviews Coding Interview FAQ · Arrays & Hashing
Short answer: Insert elements into a HashSet while scanning. If an insert fails (already present), return true. Sorting and comparing neighbors also works in O(n log n) with O(1) extra space if sorting in place is allowed.
bool ContainsDuplicate(int[] nums) {
var seen = new HashSet<int>();
foreach (int n in nums)
if (!seen.Add(n)) return true;
return false;
}
HashSet: Time O(n), Space O(n). Sort: Time O(n log n), Space O(1)/O(n).
Ask whether O(1) space matters — that steers you to sorting vs hashing.
DSA & Coding Interviews Coding Interview FAQ · Arrays & Hashing
Short answer: Valid Anagram: count character frequencies (or sort both strings). Group Anagrams: use a frequency signature or sorted string as dictionary key and bucket words together.
Valid: O(n). Group: O(n * k log k) with sort key, or O(n * k) with count key (k = word length).
Prefer count[26] for lowercase English — faster and shows constraint awareness.
DSA & Coding Interviews Coding Interview FAQ · Stacks
Short answer: Push opening brackets. On a closing bracket, pop and check it matches. At the end the stack must be empty. Covers (), {}, [] in one pass.
bool IsValid(string s) {
var st = new Stack<char>();
foreach (char c in s) {
if (c is '(' or '[' or '{') st.Push(c);
else {
if (st.Count == 0) return false;
char o = st.Pop();
if ((c == ')' && o != '(') || (c == ']' && o != '[') || (c == '}' && o != '{'))
return false;
}
}
return st.Count == 0;
}
Time O(n), Space O(n).
This is a common phone-screen opener — nail it quickly and cleanly.
DSA & Coding Interviews Coding Interview FAQ · Linked Lists
Short answer: Iterative: three pointers prev, curr, next. Flip curr.next to prev and advance. Recursive: reverse the rest, then point head.next.next = head and head.next = null. Iterative is usually preferred in interviews for O(1) stack space.
Time O(n). Iterative space O(1); recursive space O(n) call stack.
Draw 3 nodes on the whiteboard before coding — it prevents pointer bugs.
DSA & Coding Interviews Coding Interview FAQ · Linked Lists
Short answer: Use a dummy head and append the smaller of the two current nodes until one list is exhausted, then attach the remainder. Recursive merge is elegant but uses stack space.
Time O(n + m), Space O(1) iterative.
Dummy node avoids special-casing the head — a small habit that impresses interviewers.
DSA & Coding Interviews Coding Interview FAQ · Dynamic Programming
Short answer: Climbing Stairs: ways(n) = ways(n-1) + ways(n-2) — Fibonacci DP. House Robber: dp[i] = max(dp[i-1], dp[i-2] + nums[i]) — cannot rob adjacent houses. Both reduce to O(1) space with two rolling variables.
Time O(n), Space O(1) optimized.
Always define the recurrence in words before writing code.
DSA & Coding Interviews Coding Interview FAQ · Binary Search
Short answer: Maintain inclusive or exclusive bounds consistently. Compute mid carefully (lo + (hi − lo) / 2) to avoid overflow. Decide whether you want lower-bound, upper-bound, or exact match before coding.
Time O(log n), Space O(1).
State the loop invariant: “answer is always inside [lo, hi]”.
DSA & Coding Interviews Coding Interview FAQ · Interview Strategy
Short answer: Clarify inputs/outputs/constraints first. Propose brute force, then optimize. Speak while coding, test with an example, and state complexity. Silence is riskier than imperfect code with clear thinking.
Interviewers hire teammates — communication is part of the score.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: To become a Senior Software Engineer, you must show independent ownership, reliable execution, and better engineering judgment than your current level. Seniority is not about years alone; it is about scope and consistency. Build evidence that you can deliver complex work with minimal supervision.
Priya at TCS wanted to move from SDE-1 to senior responsibilities but mostly handled small tickets. Rahul from Razorpay advised her to own one reliability initiative end to end and document business impact. She reduced failure rates in a core workflow and mentored two junior engineers through release cycles. In her next review cycle, she was rated for senior-track readiness.
Senior title follows consistent ownership evidence.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: Solution Architects bridge business needs and technical implementation. You need enough technical depth to design feasible systems and enough communication skill to align non-technical stakeholders. Business understanding is as important as architecture knowledge.
Karan at Razorpay wanted to move from backend engineer to solution-oriented role. Isha from PhonePe advised him to join discovery calls and write architecture summaries for client-facing discussions. He learned to translate payment workflow constraints into clear integration options. This visibility helped him move toward a Solution Architect track internally.
Solution architects win through business-technical translation.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: Faster promotions come from visible impact on high-priority problems, not extra hours alone. If your work consistently reduces risk, saves cost, or accelerates delivery, promotion discussions become easier. Visibility and evidence are critical.
Ananya at PhonePe wanted a promotion but had no structured evidence during reviews. Vikram helped her create a quarterly impact tracker covering uptime, delivery, and cross-team collaboration outcomes. She chose one critical reliability project and communicated progress consistently. Her promotion discussion became stronger and data-backed.
Promotions accelerate when impact is visible and role-aligned.
Career Growth Career & HR Interview Guide · Career Growth
Short answer: A career growth plan turns vague ambition into measurable actions. It should define your target role, current gap, timeline, and progress checkpoints. Without a plan, growth becomes reactive and slower.
Meera at Infosys wanted to move from support engineering to product backend but had no clear roadmap. Rohit from Freshworks helped her define a 12-month plan with stack goals, project milestones, and interview checkpoints. She reviewed progress every quarter with her mentor and updated strategy based on feedback. The structure kept her focused and accelerated her transition.
If it is not scheduled, it rarely happens.
DSA & Coding Interviews Coding Interview FAQ · Linked Lists
Short answer: Floyd’s tortoise and hare: slow moves 1, fast moves 2. If they meet, there is a cycle. To find the cycle entrance, reset one pointer to head and move both one step until they meet.
Time O(n), Space O(1) — better than HashSet of visited nodes.
Mention both HashSet and Floyd; then choose Floyd for O(1) space.
DSA & Coding Interviews Coding Interview FAQ · Graphs
Short answer: BFS uses a queue and finds shortest paths in unweighted graphs / level order. DFS uses a stack/recursion and is natural for path existence, cycle detection, topological sort, and flood fill. Pick based on what “best” means.
If the question says “shortest” on an unweighted graph, default to BFS.