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 726–750 of 3281

Career & HR topics

By tech stack

Popular tracks

Mid PDF
How would you implement a custom collection in C#?

Short answer: To implement a custom collection: Derive from existing base classes like Collection<T>, List<T>, or implement interfaces such as ICollection<T>, IEnumerable<T>, or IList<T>. Ex…

Collections Read answer
Mid PDF
Check if a string has balanced brackets?

Short answer: public bool IsBalanced(string s) { Stack<char> stack = new Stack<char>(); Dictionary<char, char> pairs = new Dictionary<char, char> { {')', '('}, {']', '['}, {'}', '{'} }; foreach (c…

Coding Read answer
Mid PDF
Word Break II (all possible sentences)?

Short answer: List<string> WordBreak(string s, IList<string> wordDict) { Example code var wordSet = new HashSet<string>(wordDict); var memo = new Dictionary<int, List<string>>(); return DFS(…

Coding Read answer
Mid PDF
Find the maximum width of a binary tree?

Short answer: int WidthOfBinaryTree(TreeNode root) { if (root == null) return 0; int maxWidth = 0; Queue<(TreeNode node, int idx)> queue = new Queue<(TreeNode, int)>(); queue.Enqueue((root, 0)); while (queue.…

Coding Read answer
Mid PDF
Solve Sudoku (Backtracking)?

Short answer: bool SolveSudoku(char[][] board) { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Follow on: if (board[i][j] == '.') { for (char c = '1'; c <= '9'; c++) { if (IsValid(board, i, j, c))…

Coding Read answer
Mid PDF
Sort Array of 0s, 1s, and 2s (Dutch National Flag)?

Short answer: void SortColors(int[] nums) { Example code int low = 0, mid = 0, high = nums.Length - 1; while (mid <= high) { if (nums[mid] == 0) (nums[low++], nums[mid++]) = (nums[mid], nums[low]); else if (nums[mid]…

Coding Read answer
Mid PDF
Matrix Chain Multiplication?

Short answer: int MatrixChainOrder(int[] dims) { int n = dims.Length - 1; int[,] dp = new int[n, n]; for (int l = 2; l <= n; l++) { Follow on: for (int i = 0; i < n - l + 1; i++) { int j = i + l - 1; dp[i, j] = int…

Coding Read answer
Mid PDF
Reverse words in a sentence?

Short answer: string input = "I love dotnet"; string[] words = input.Split(' '); Array.Reverse(words); string result = string.Join(" ", words); Example code string input = "I love dotnet"; s…

Coding Scenarios Read answer
Mid PDF
Reverse words in a sentence string input = "I love dotnet"; string[] words = input.Split(' ');?

Short answer: rray.Reverse(words); string result = string.Join(" ", words); rray.Reverse(words); string result = string.Join(" ", words); rray.Reverse(words); string result = string.Join(" "…

Coding Scenarios Read answer
Mid PDF
Rotate a matrix by 90 degrees in place public void RotateMatrix(int[][] matrix) { int n = matrix.Length; // Transpose for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int temp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = temp; } } // Reverse each row for (int i = 0; i < n; i++) {

Short answer: rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise. Explain a bit more rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse e…

Coding Read answer
Mid PDF
Rotate a matrix by 90 degrees in place?

Short answer: public void RotateMatrix(int[][] matrix) { int n = matrix.Length; // Transpose for (int i = 0; i &lt; n; i++) { for (int j = i + 1; j &lt; n; j++) { int temp = matrix[i][j]; matrix[i][j] = matrix[j][i]; mat…

Coding Read answer
Mid PDF
Generate Parentheses (Well-formed Combinations)?

Short answer: Follow on: List&lt;string&gt; GenerateParenthesis(int n) if (open &lt; max) Generate(current + &quot;(&quot;, open + 1, close, max, result); if (close &lt; open) Generate(current + &quot;)&quot;, open, clos…

Coding Read answer
Mid PDF
Find Largest Prime Factor of a Number?

Short answer: long LargestPrimeFactor(long n) { Example code long maxPrime = -1; while (n % 2 == 0) { maxPrime = 2; n /= 2; } for (long i = 3; i * i &lt;= n; i += 2) { while (n % i == 0) { maxPrime = i; n /= i; } } if (n…

Coding Read answer
Mid PDF
Find Missing Number in Sorted Array of Distinct?

Short answer: Integers int FindMissingNumber(int[] nums) { int low = 0, high = nums.Length - 1; while (low &lt;= high) { int mid = low + (high - low) / 2; if (nums[mid] == mid) low = mid + 1; else high = mid - 1; } retur…

Coding Read answer
Mid PDF
Partition Problem (Equal Sum Subset)?

Short answer: bool CanPartition(int[] nums) { int sum = nums.Sum(); Follow on: if (sum % 2 != 0) return false; int target = sum / 2; bool[] dp = new bool[target + 1]; dp[0] = true; foreach (int num in nums) { for (int j…

Coding Read answer
Mid PDF
Check palindrome string?

Short answer: bool IsPalindrome(string str) { int left = 0, right = str.Length - 1; while (left &lt; right) { if (str[left] != str[right]) return false; left++; right--; } return true; } Example code bool IsPalindrome(st…

Coding Scenarios Read answer
Mid PDF
First repeating element in array?

Short answer: int[] arr = { 3, 5, 1, 5, 2 }; HashSet&lt;int&gt; set = new HashSet&lt;int&gt;(); foreach (int num in arr) { if (!set.Add(num)) { Console.WriteLine(num); break; } } Example code int[] arr = { 3, 5, 1, 5, 2…

Coding Scenarios Read answer
Mid PDF
Merge two sorted arrays?

Short answer: int[] a = { 1, 3, 5 }; int[] b = { 2, 4, 6 }; int i = 0, j = 0; List&lt;int&gt; result = new List&lt;int&gt;(); while (i &lt; a.Length &amp;&amp; j &lt; b.Length) result.Add(a[i] &lt; b[j] ? a[i++] : b[j++]…

Coding Scenarios Read answer
Mid PDF
Longest word in a sentence?

Short answer: string sentence = &quot;CSharp makes backend development powerful&quot;; string[] words = sentence.Split(' '); string longest = words[0]; foreach (string word in words) { if (word.Length &gt; longest.Length…

Coding Scenarios Read answer
Mid PDF
Flatten a nested list?

Short answer: List&lt;object&gt; list = new List&lt;object&gt; { 1, new List&lt;int&gt; { 2, 3 }, 4 }; List&lt;int&gt; result = new List&lt;int&gt;(); void Flatten(List&lt;object&gt; input) { foreach (var item in input)…

Coding Scenarios Read answer
Mid PDF
Custom sorting (Bubble Sort)?

Short answer: int[] arr = { 5, 1, 4, 2 }; for (int i = 0; i &lt; arr.Length; i++) { for (int j = 0; j &lt; arr.Length - 1; j++) { if (arr[j] &gt; arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; }…

Coding Scenarios Read answer
Mid PDF
Custom sorting (Bubble Sort) int[] arr = { 5, 1, 4, 2 }; for (int i = 0; i < arr.Length; i++) { for (int j = 0; j < arr.Length - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j];

Short answer: rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } Real-world example (ShopNest)…

Coding Scenarios Read answer
Mid PDF
Character frequency (case-insensitive)?

Short answer: string input = &quot;DotNet&quot;; Dictionary&lt;char, int&gt; map = new Dictionary&lt;char, int&gt;(); foreach (char c in input.ToLower()) map[c] = map.ContainsKey(c) ? map[c] + 1 : 1; Example code string…

Coding Scenarios Read answer
Mid PDF
Check if array is sorted (ascending)?

Short answer: bool IsSorted(int[] arr) { for (int i = 0; i &lt; arr.Length - 1; i++) { if (arr[i] &gt; arr[i + 1]) return false; } return true; } Example code bool IsSorted(int[] arr) { for (int i = 0; i &lt; arr.Length…

Coding Scenarios Read answer
Mid PDF
Remove special characters from string?

Short answer: string result = sb.ToString(); Final Notes These questions frequently appear in L1/L2 interviews They test logic clarity, memory, and problem-solving Ideal for LinkedIn posts, reels, ebooks, and interviews…

Coding Scenarios Read answer

C# Collections C# Programming Tutorial · Collections

Short answer: To implement a custom collection: Derive from existing base classes like Collection<T>, List<T>, or implement interfaces such as ICollection<T>, IEnumerable<T>, or IList<T>.

Explain a bit more

Override or implement necessary methods like Add(), Remove(), GetEnumerator(), and indexers. Provide custom behavior, validation, or constraints as needed. Example: public class MyCustomCollection<T> : Collection<T> { protected override void InsertItem(int index, T item) { // Custom validation if (item == null) throw new ArgumentNullException(nameof(item)); base.InsertItem(index, item); }

Real-world example (ShopNest)

In ShopNest checkout, choose the collection by need: List for ordered cart lines, Dictionary for fast SKU lookup, HashSet for unique tags.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: public bool IsBalanced(string s) { Stack<char> stack = new Stack<char>(); Dictionary<char, char> pairs = new Dictionary<char, char> { {')', '('}, {']', '['}, {'}', '{'} }; foreach (char c in s) { if ("([{".Contains(c)) stack.Push(c); else if (")]}".Contains(c)) { if (stack.Count == 0 || stack.Pop() != pairs[c]) return false; } } return stack.Count == 0; } Follow on: Explanation: Use a stack to match opening and…

Example code

public bool IsBalanced(string s) {
Stack<char> stack = new Stack<char>();
Dictionary<char, char> pairs = new Dictionary<char, char> { {')', '('}, {']', '['}, {'}', '{'} }; foreach (char c in s) {
if ("([{".Contains(c)) stack.Push(c); else if (")]}".Contains(c)) { if (stack.Count == 0 || stack.Pop() != pairs[c])
return false;
}
}
return stack.Count == 0;
} Follow on: Explanation: Use a stack to match opening and closing brackets properly.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: List<string> WordBreak(string s, IList<string> wordDict) {

Example code

var wordSet = new HashSet<string>(wordDict);
var memo = new Dictionary<int, List<string>>();
return DFS(0);
List<string> DFS(int start) {
if (memo.ContainsKey(start)) return memo[start];
var res = new List<string>();
if (start == s.Length) { res.Add(""); return res;
}
for (int end = start + 1; end <= s.Length; end++) {
string word = s.Substring(start, end - start);
if (wordSet.Contains(word)) {
foreach (var sub in DFS(end)) {
string space = sub.Length == 0 ? "" : " "; res.Add(word + space + sub); }
}
}
memo[start] = res;
return res;
}
} Follow on:

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: int WidthOfBinaryTree(TreeNode root) { if (root == null) return 0; int maxWidth = 0; Queue<(TreeNode node, int idx)> queue = new Queue<(TreeNode, int)>(); queue.Enqueue((root, 0)); while (queue.Count > 0) { int size = queue.Count; int start = queue.Peek().idx; int end = start; for (int i = 0; i < size; i++) { var (node, idx) = queue.Dequeue(); end = idx; if (node.left != null) queue.Enqueue((node.left, 2 * idx +…

Explain a bit more

1)); if (node.right != null) queue.Enqueue((node.right, 2 * idx + 2)); } maxWidth = Math.Max(maxWidth, end - start + 1); Follow on: } return maxWidth; } Explanation: Assign index to each node as if in a complete tree; width is max difference of indices per level.

Example code

int WidthOfBinaryTree(TreeNode root) {
if (root == null) return 0;
int maxWidth = 0; Queue<(TreeNode node, int idx)> queue = new Queue<(TreeNode, int)>(); queue.Enqueue((root, 0)); while (queue.Count > 0) { int size = queue.Count;
int start = queue.Peek().idx;
int end = start;
for (int i = 0; i < size; i++) {
var (node, idx) = queue.Dequeue();
end = idx;
if (node.left != null) queue.Enqueue((node.left, 2 * idx + 1)); if (node.right != null) queue.Enqueue((node.right, 2 * idx + 2)); }
maxWidth = Math.Max(maxWidth, end - start + 1); Follow on: }
return maxWidth;
} Explanation: Assign index to each node as if in a complete tree; width is max difference of indices per level.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: bool SolveSudoku(char[][] board) { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Follow on: if (board[i][j] == '.') { for (char c = '1'; c <= '9'; c++) { if (IsValid(board, i, j, c)) { board[i][j] = c; if (SolveSudoku(board)) return true; else board[i][j] = '.'; } } return false; } } } return true; } bool IsValid(char[][] board, int row, int col, char c) { for (int i = 0; i < 9; i++) { if…

Explain a bit more

(board[row][i] == c) return false; if (board[i][col] == c) return false; if (board[3 * (row / 3) + i / 3][3 * (col / 3) + i % 3] == c) return false; } return true; } Explanation: Backtracking tries digits 1-9 in empty cells, validating constraints.

Example code

bool SolveSudoku(char[][] board) {
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{ Follow on: if (board[i][j] == '.')
{
for (char c = '1'; c <= '9'; c++)
{
if (IsValid(board, i, j, c))
{
board[i][j] = c;
if (SolveSudoku(board))
return true; else board[i][j] = '.';
}
}
return false;
}
}
}
return true;
} bool IsValid(char[][] board, int row, int col, char c) {
for (int i = 0; i < 9; i++)
{
if (board[row][i] == c) return false;
if (board[i][col] == c) return false;
if (board[3 * (row / 3) + i / 3][3 * (col / 3) + i % 3] == c) return false; }
return true;
} Explanation: Backtracking tries digits 1-9 in empty cells, validating constraints.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: void SortColors(int[] nums) {

Example code

int low = 0, mid = 0, high = nums.Length - 1; while (mid <= high) {
if (nums[mid] == 0)
(nums[low++], nums[mid++]) = (nums[mid], nums[low]); else if (nums[mid] == 1) mid++; else (nums[mid], nums[high--]) = (nums[high], nums[mid]);
}
} Follow on: Explanation: Partition array into three parts in one pass using three pointers.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: int MatrixChainOrder(int[] dims) { int n = dims.Length - 1; int[,] dp = new int[n, n]; for (int l = 2; l <= n; l++) { Follow on: for (int i = 0; i < n - l + 1; i++) { int j = i + l - 1; dp[i, j] = int.MaxValue; for (int k = i; k < j; k++) { int cost = dp[i, k] + dp[k + 1, j] + dims[i] * dims[k + 1] * dims[j + 1]; dp[i, j] = Math.Min(dp[i, j], cost); } } } return dp[0, n - 1]; } Explanation: DP calculates minimal…

Explain a bit more

cost to multiply chain of matrices by trying all partitions.

Example code

int MatrixChainOrder(int[] dims)
{
int n = dims.Length - 1;
int[,] dp = new int[n, n];
for (int l = 2; l <= n; l++)
{ Follow on: for (int i = 0; i < n - l + 1; i++)
{
int j = i + l - 1;
dp[i, j] = int.MaxValue;
for (int k = i; k < j; k++)
{
int cost = dp[i, k] + dp[k + 1, j] + dims[i] * dims[k + 1] * dims[j + 1]; dp[i, j] = Math.Min(dp[i, j], cost);
}
}
}
return dp[0, n - 1];
} Explanation: DP calculates minimal cost to multiply chain of matrices by trying all partitions.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: string input = "I love dotnet"; string[] words = input.Split(' '); Array.Reverse(words); string result = string.Join(" ", words);

Example code

string input = "I love dotnet";
string[] words = input.Split(' '); Array.Reverse(words); string result = string.Join(" ", words);

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: rray.Reverse(words); string result = string.Join(" ", words); rray.Reverse(words); string result = string.Join(" ", words); rray.Reverse(words); string result = string.Join(" ", words); rray.Reverse(words); string result = string.Join(" ", words);

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise.

Explain a bit more

rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise. rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise. rray.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: public void RotateMatrix(int[][] matrix) { int n = matrix.Length; // Transpose for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int temp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = temp; } } // Reverse each row for (int i = 0; i < n; i++) { Array.Reverse(matrix[i]); } } Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise.

Example code

public void RotateMatrix(int[][] matrix) {
int n = matrix.Length; // Transpose for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
} // Reverse each row for (int i = 0; i < n; i++) { Array.Reverse(matrix[i]); }
} Explanation: Transpose matrix and then reverse each row to rotate 90° clockwise.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: Follow on: List<string> GenerateParenthesis(int n) if (open < max) Generate(current + "(", open + 1, close, max, result); if (close < open) Generate(current + ")", open, close + 1, max, result); } Explanation: Use backtracking to add '(' and ')' only when valid.

Example code

{
List<string> result = new List<string>(); Generate("", 0, 0, n, result); return result;
} void Generate(string current, int open, int close, int max, List<string> result)
{
if (current.Length == max * 2)
{ result.Add(current); return;
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: long LargestPrimeFactor(long n) {

Example code

long maxPrime = -1; while (n % 2 == 0) {
maxPrime = 2;
n /= 2;
}
for (long i = 3; i * i <= n; i += 2)
{ while (n % i == 0) {
maxPrime = i;
n /= i;
}
}
if (n > 2) maxPrime = n;
return maxPrime;
} Follow on: Explanation: Divide out factors of 2, then test odd factors; leftover > 2 is prime. Miscellaneous Problems

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: Integers int FindMissingNumber(int[] nums) { int low = 0, high = nums.Length - 1; while (low <= high) { int mid = low + (high - low) / 2; if (nums[mid] == mid) low = mid + 1; else high = mid - 1; } return low; } Explanation: In perfect array nums[i] == i; missing number breaks this property, use binary search to find breakpoint. Mathematical Problems

Example code

Integers
int FindMissingNumber(int[] nums)
{
int low = 0, high = nums.Length - 1; while (low <= high) {
int mid = low + (high - low) / 2;
if (nums[mid] == mid)
low = mid + 1; else high = mid - 1;
}
return low;
} Explanation: In perfect array nums[i] == i; missing number breaks this property, use binary search to find breakpoint. Mathematical Problems

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding

Short answer: bool CanPartition(int[] nums) { int sum = nums.Sum(); Follow on: if (sum % 2 != 0) return false; int target = sum / 2; bool[] dp = new bool[target + 1]; dp[0] = true; foreach (int num in nums) { for (int j = target; j >= num; j--) { dp[j] = dp[j] || dp[j - num]; } } return dp[target]; } Explanation: Subset sum to check if half the total sum is achievable. Sorting and Searching

Example code

bool CanPartition(int[] nums) {
int sum = nums.Sum(); Follow on: if (sum % 2 != 0) return false;
int target = sum / 2;
bool[] dp = new bool[target + 1];
dp[0] = true;
foreach (int num in nums)
{
for (int j = target; j >= num; j--)
{
dp[j] = dp[j] || dp[j - num];
}
}
return dp[target];
} Explanation: Subset sum to check if half the total sum is achievable. Sorting and Searching

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: bool IsPalindrome(string str) { int left = 0, right = str.Length - 1; while (left < right) { if (str[left] != str[right]) return false; left++; right--; } return true; }

Example code

bool IsPalindrome(string str) {
int left = 0, right = str.Length - 1; while (left < right) {
if (str[left] != str[right])
return false; left++; right--; }
return true;
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: int[] arr = { 3, 5, 1, 5, 2 }; HashSet<int> set = new HashSet<int>(); foreach (int num in arr) { if (!set.Add(num)) { Console.WriteLine(num); break; } }

Example code

int[] arr = { 3, 5, 1, 5, 2 };
HashSet<int> set = new HashSet<int>();
foreach (int num in arr)
{
if (!set.Add(num))
{ Console.WriteLine(num); break; }
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: int[] a = { 1, 3, 5 }; int[] b = { 2, 4, 6 }; int i = 0, j = 0; List<int> result = new List<int>(); while (i < a.Length && j < b.Length) result.Add(a[i] < b[j] ? a[i++] : b[j++]); while (i < a.Length) result.Add(a[i++]); while (j < b.Length) result.Add(b[j++]);

Example code

int[] a = { 1, 3, 5 };
int[] b = { 2, 4, 6 };
int i = 0, j = 0;
List<int> result = new List<int>(); while (i < a.Length && j < b.Length) result.Add(a[i] < b[j] ? a[i++] : b[j++]); while (i < a.Length) result.Add(a[i++]); while (j < b.Length) result.Add(b[j++]);

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: string sentence = "CSharp makes backend development powerful"; string[] words = sentence.Split(' '); string longest = words[0]; foreach (string word in words) { if (word.Length > longest.Length) longest = word; }

Example code

string sentence = "CSharp makes backend development powerful";
string[] words = sentence.Split(' ');
string longest = words[0];
foreach (string word in words)
{
if (word.Length > longest.Length)
longest = word;
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: List<object> list = new List<object> { 1, new List<int> { 2, 3 }, 4 }; List<int> result = new List<int>(); void Flatten(List<object> input) { foreach (var item in input) { if (item is int) result.Add((int)item); else Flatten((List<object>)item); } }

Example code

List<object> list = new List<object> { 1, new List<int> { 2, 3 }, 4 }; List<int> result = new List<int>(); void Flatten(List<object> input) {
foreach (var item in input)
{
if (item is int) result.Add((int)item); else Flatten((List<object>)item); }
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: int[] arr = { 5, 1, 4, 2 }; for (int i = 0; i < arr.Length; i++) { for (int j = 0; j < arr.Length - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } }

Example code

int[] arr = { 5, 1, 4, 2 };
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } } rr[j] = arr[j + 1]; rr[j + 1] = temp; } } }

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: string input = "DotNet"; Dictionary<char, int> map = new Dictionary<char, int>(); foreach (char c in input.ToLower()) map[c] = map.ContainsKey(c) ? map[c] + 1 : 1;

Example code

string input = "DotNet";
Dictionary<char, int> map = new Dictionary<char, int>();
foreach (char c in input.ToLower())
map[c] = map.ContainsKey(c) ? map[c] + 1 : 1;

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: bool IsSorted(int[] arr) { for (int i = 0; i < arr.Length - 1; i++) { if (arr[i] > arr[i + 1]) return false; } return true; }

Example code

bool IsSorted(int[] arr) {
for (int i = 0; i < arr.Length - 1; i++)
{
if (arr[i] > arr[i + 1])
return false;
}
return true;
}

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# Coding Interview C# Programming Tutorial · Coding Scenarios

Short answer: string result = sb.ToString(); Final Notes These questions frequently appear in L1/L2 interviews They test logic clarity, memory, and problem-solving Ideal for LinkedIn posts, reels, ebooks, and interviews

Example code

string input = "Dot@Net#2024!";
StringBuilder sb = new StringBuilder();
foreach (char c in input)
{
if (char.IsLetterOrDigit(c)) sb.Append(c); }

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
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