Top 30 Most Common Deloitte Coding Questions You Should Prepare For

Written by
James Miller, Career Coach
Landing a position at a prestigious firm like Deloitte often involves navigating a rigorous interview process, and for technical roles, this means mastering the coding interview. Deloitte coding questions are designed to evaluate your problem-solving abilities, grasp of fundamental computer science concepts, and coding proficiency under pressure. They typically span a range of topics, from core data structures and algorithms to more advanced areas like dynamic programming and system design fundamentals. Preparing effectively requires focused study and practice on the types of problems you're likely to encounter. This guide aims to provide a comprehensive overview of some of the most common technical questions asked in Deloitte interviews, offering insights into what interviewers look for and how to structure your responses. By familiarizing yourself with these prevalent question types and practicing similar problems, you can significantly boost your confidence and performance during your Deloitte coding interviews. Success in these interviews hinges not just on finding a correct solution, but also on demonstrating clear thought processes, ability to handle edge cases, and writing clean, efficient code. Let's dive into the types of questions that frequently appear and how to approach them strategically.
What Are Deloitte Coding Questions?
Deloitte coding questions are technical challenges posed during the interview process for technology-focused roles. These questions assess a candidate's ability to write code that is correct, efficient, and handles various scenarios. They primarily focus on fundamental computer science principles. Common areas include data structures like arrays, linked lists, trees, stacks, queues, hash maps, and graphs. Algorithms frequently tested involve sorting, searching, recursion, dynamic programming, and graph traversal techniques (like DFS and BFS). String manipulation problems, mathematical logic, and sometimes basic object-oriented programming concepts or system design discussions also feature. The level of difficulty can range from easy to medium, with some harder questions appearing for more senior roles. Candidates are expected to not only provide a working solution but also discuss its time and space complexity and justify their approach. The ability to communicate your thought process clearly is as crucial as the code itself.
Why Do Interviewers Ask Deloitte Coding Questions?
Deloitte interviewers use coding questions as a primary tool to evaluate several key attributes of a candidate. Firstly, they assess problem-solving skills; how a candidate breaks down a complex problem into smaller, manageable parts and devises a logical approach. Secondly, they test fundamental knowledge of computer science concepts, ensuring the candidate has a solid understanding of data structures and algorithms, which are the building blocks of efficient software. Thirdly, they gauge coding proficiency, including syntax, logic implementation, handling edge cases, and writing clean, readable code. Efficiency (time and space complexity) is also a major consideration, indicating whether a candidate can write scalable solutions. Finally, coding interviews evaluate communication skills. Candidates must explain their logic, discuss trade-offs, and respond to feedback or hints from the interviewer. It's a holistic assessment of technical ability and communication under pressure.
Reverse a string.
Check if a string is a palindrome.
Find the first non-repeating character in a string.
Check if two strings are anagrams.
Implement binary search on a sorted array.
Find the maximum sum subarray.
Remove duplicates from a sorted array in-place.
Merge two sorted arrays.
Find the Nth Fibonacci number using dynamic programming.
Implement factorial calculation recursively and iteratively.
Reverse a linked list.
Detect cycle in a linked list.
Merge two sorted linked lists.
Implement a stack using arrays or linked lists.
Implement a queue using arrays or linked lists.
Perform inorder, preorder, and postorder tree traversals.
Find the height of a binary tree.
Implement breadth-first search (BFS) for a graph.
Implement depth-first search (DFS) for a graph.
Check if a number is prime.
Calculate the Greatest Common Divisor (GCD) of two numbers.
Find pairs in an array with a given sum.
Rotate an array by k positions.
Find the missing number in a range.
Implement quicksort or mergesort.
Explain OOP concepts: Inheritance, Polymorphism, Encapsulation, Abstraction.
Compare abstract class and interface.
Find the lowest common ancestor (LCA) of two nodes in a binary tree.
Find the longest common subsequence (LCS) of two strings.
Implement atoi (string to integer).
Preview List
1. Reverse a string.
Why you might get asked this:
Tests basic string manipulation skills, array indexing, and loop constructs. Simple but foundational.
How to answer:
Use two pointers, one starting from the beginning and one from the end, swapping characters until they meet in the middle.
Example answer:
Iterate with left=0, right=length-1. While left < right, swap str[left] and str[right], then increment left, decrement right. Return the modified string.
2. Check if a string is a palindrome.
Why you might get asked this:
Evaluates string access and comparison, often using a two-pointer approach similar to string reversal.
How to answer:
Compare characters from the start and end simultaneously, moving inwards. If any pair doesn't match, it's not a palindrome.
Example answer:
Use left=0, right=length-1. While left < right, if str[left] != str[right], return false. Increment left, decrement right. If loop finishes, return true. Ignore case/non-alphanumeric if specified.
3. Find the first non-repeating character in a string.
Why you might get asked this:
Tests hash map usage for character counting or frequency analysis.
How to answer:
Use a hash map (or frequency array) to count character occurrences. Then iterate through the string again, returning the first character with a count of 1.
Example answer:
Create map char -> count
. Iterate string once to populate map. Iterate string second time. If map[char] == 1, return char. If no such char, return special value.
4. Check if two strings are anagrams.
Why you might get asked this:
Assesses understanding of character frequencies and sorting/hashing techniques.
How to answer:
Option 1: Sort both strings and check if they are equal. Option 2: Use a frequency map (or array) to count characters in the first string and decrement for the second. Check if counts are zero.
Example answer:
If lengths differ, return false. Use a 26-element array for counts. Increment for string1, decrement for string2. Check if all array elements are zero.
5. Implement binary search on a sorted array.
Why you might get asked this:
A fundamental algorithm question testing divide-and-conquer logic and handling indices.
How to answer:
Repeatedly divide the search interval in half. Compare the middle element to the target. Adjust the interval (left or right) based on the comparison.
Example answer:
Initialize left=0, right=n-1. While left <= right, calculate mid = left + (right-left)/2. If arr[mid] == target, return mid. If arr[mid] < target, left = mid + 1. Else right = mid - 1. Return -1 if not found.
6. Find the maximum sum subarray.
Why you might get asked this:
Introduces dynamic programming or Kadane's algorithm, testing optimization skills on arrays.
How to answer:
Kadane's algorithm: Track the maximum sum ending at the current position and the overall maximum sum found so far.
Example answer:
Initialize max\_so\_far = arr[0], current\_max = arr[0]. Iterate from index 1: current\_max = max(arr[i], current\_max + arr[i]). max\_so\_far = max(max\_so\_far, current\_max). Return max\_so\_far.
7. Remove duplicates from a sorted array in-place.
Why you might get asked this:
Tests array manipulation and space optimization by modifying the array directly.
How to answer:
Use a two-pointer approach. One pointer (i
) tracks the position for the next unique element, the other (j
) iterates through the array. Copy element at j
to position i
only if it's different from the previous element at i-1
.
Example answer:
Use pointer i=0
. Iterate j
from 1 to n-1. If arr[j] != arr[i], increment i
and set arr[i] = arr[j]. The number of unique elements is i+1
. Return i+1
.
8. Merge two sorted arrays.
Why you might get asked this:
Assesses merging techniques, often requiring efficient use of space (e.g., merging into one of the arrays if large enough).
How to answer:
Use three pointers: one for the end of the first array, one for the end of the second, and one for the end of the merged array (starting from the last position). Compare elements and place the larger one at the current merged position, moving the corresponding pointer back.
Example answer:
Given nums1 (size m+n) and nums2 (size n), merge into nums1. Use pointers p1=m-1, p2=n-1, p=m+n-1. While p1>=0 and p2>=0, if nums1[p1] > nums2[p2], nums1[p]=nums1[p1--] else nums1[p]=nums2[p2--]. Copy remaining elements.
9. Find the Nth Fibonacci number using dynamic programming.
Why you might get asked this:
Classic DP problem to check understanding of memoization or tabulation for optimization.
How to answer:
Use memoization (top-down recursion with caching) or tabulation (bottom-up iterative filling of an array). Avoid simple recursion due to repeated calculations.
Example answer:
Tabulation: Create array dp
of size n+1. Set dp[0]=0, dp[1]=1. Iterate from i=2 to n, dp[i] = dp[i-1] + dp[i-2]. Return dp[n].
10. Implement factorial calculation recursively and iteratively.
Why you might get asked this:
Compares recursive vs. iterative approaches, highlighting recursion's base case and step, and potential stack overflow issues.
How to answer:
Recursive: Base case: fact(0)=1. Recursive step: fact(n) = n * fact(n-1). Iterative: Use a loop to multiply numbers from 1 to n.
Example answer:
Recursive: if n==0 return 1; return n factorial(n-1);
. Iterative: result=1; for i=1 to n: result = i; return result;
.
11. Reverse a linked list.
Why you might get asked this:
Fundamental linked list manipulation, requiring careful pointer handling.
How to answer:
Iterate through the list, changing the next
pointer of each node to point to its previous node. Use three pointers: prev
, curr
, next_node
.
Example answer:
Initialize prev = null
, curr = head
. While curr
is not null: nextnode = curr->next
, curr->next = prev
, prev = curr
, curr = nextnode
. Return prev
.
12. Detect cycle in a linked list.
Why you might get asked this:
Tests understanding of list traversal and cycle detection algorithms (Floyd's Tortoise and Hare).
How to answer:
Use two pointers, one slow (moves one step at a time) and one fast (moves two steps). If they meet, there is a cycle.
Example answer:
Initialize slow = head
, fast = head
. While fast
is not null and fast->next
is not null: slow = slow->next
, fast = fast->next->next
. If slow == fast
, return true. Return false if loop finishes.
13. Merge two sorted linked lists.
Why you might get asked this:
Combines list manipulation with merging logic, similar to merging sorted arrays but with pointers.
How to answer:
Use a dummy node to simplify edge cases. Iterate through both lists, appending the smaller node to the merged list, advancing the corresponding pointer. Append any remaining nodes.
Example answer:
Create dummy
node, tail = dummy
. While list1 and list2 are not null: if list1->val <= list2->val, tail->next = list1
, list1 = list1->next
. Else tail->next = list2
, list2 = list2->next
. tail = tail->next
. Append remaining. Return dummy->next
.
14. Implement a stack using arrays or linked lists.
Why you might get asked this:
Checks understanding of ADT (Abstract Data Type) implementation using underlying structures.
How to answer:
Array: Use an array and an integer top
to track the top element. Push: increment top
, add element. Pop: decrement top
, return element. Linked List: Use a singly linked list. Push: add node to the head. Pop: remove node from the head.
Example answer:
Using Linked List: push(val)
: new Node(val), newnode->next = top, top = newnode. pop()
: if top==null, error. temp = top, top = top->next, return temp->val. peek()
: return top->val.
15. Implement a queue using arrays or linked lists.
Why you might get asked this:
Similar to stack implementation, testing understanding of queue's FIFO (First-In, First-Out) behavior.
How to answer:
Array: Use array and front
/rear
pointers (handle wrapping for fixed size). Linked List: Use a singly linked list with pointers to both front
and rear
. Enqueue (add) at rear, Dequeue (remove) from front.
Example answer:
Using Linked List: enqueue(val)
: new Node(val). If rear is null, front=rear=newnode. Else rear->next = newnode, rear = new_node. dequeue()
: if front is null, error. temp=front, front=front->next. If front null, rear=null. Return temp->val.
16. Perform inorder, preorder, and postorder tree traversals.
Why you might get asked this:
Fundamental tree algorithms, testing recursion and iterative approaches using stacks.
How to answer:
Inorder: Left -> Root -> Right. Preorder: Root -> Left -> Right. Postorder: Left -> Right -> Root. Explain recursive logic or iterative logic using a stack.
Example answer:
Recursive Inorder: inorder(node): if node is null return; inorder(node->left); visit(node); inorder(node->right);
. Other traversals follow similar recursive patterns.
17. Find the height of a binary tree.
Why you might get asked this:
Recursive tree problem testing base cases and combining results from subproblems.
How to answer:
Recursively calculate the height of the left and right subtrees. The height of the tree is 1 + the maximum of the left and right subtree heights. Base case: height of an empty tree is -1 or 0 depending on definition.
Example answer:
height(node): if node is null return -1; return 1 + max(height(node->left), height(node->right));
. Or 0 for null and 1 + max for non-null depending on convention.
18. Implement breadth-first search (BFS) for a graph.
Why you might get asked this:
Fundamental graph traversal, testing queue usage and level-by-level exploration.
How to answer:
Use a queue and a set (or visited array) to keep track of visited nodes. Start from a source node, add to queue and mark visited. While queue is not empty, dequeue a node, visit it, and enqueue its unvisited neighbors.
Example answer:
Queue q
, Set visited
. Add start node to q
, visited
. While q
not empty: u = q.dequeue()
. Process u
. For each neighbor v
of u
: if v
not in visited
, add v
to visited
, q.enqueue(v)
.
19. Implement depth-first search (DFS) for a graph.
Why you might get asked this:
Fundamental graph traversal, testing recursion or stack usage and exploring deeply before backtracking.
How to answer:
Use recursion (implicit stack) or an explicit stack and a set (or visited array). Start from a source node, mark visited. For each unvisited neighbor, recursively call DFS (or push onto stack).
Example answer:
Recursive: dfs(u, visited): mark u visited. Process u. For each neighbor v of u: if v not visited, dfs(v, visited)
. Iterative uses explicit stack.
20. Check if a number is prime.
Why you might get asked this:
Basic mathematical logic and loop optimization (checking divisibility up to sqrt(n)).
How to answer:
Iterate from 2 up to the square root of the number. If any number in this range divides the given number evenly, it's not prime. Handle edge cases like 0, 1, 2.
Example answer:
If n <= 1, return false. If n == 2, return true. If n % 2 == 0, return false. For i from 3 to sqrt(n) with step 2: if n % i == 0, return false. Return true.
21. Calculate the Greatest Common Divisor (GCD) of two numbers.
Why you might get asked this:
Tests basic mathematical algorithms, often using the Euclidean algorithm for efficiency.
How to answer:
Use the Euclidean algorithm: GCD(a, b) = GCD(b, a % b) until b becomes 0. The result is the value of a at that point.
Example answer:
gcd(a, b): if b == 0 return a; return gcd(b, a % b);
. Ensure non-negative inputs or handle signs.
22. Find pairs in an array with a given sum.
Why you might get asked this:
Evaluates array traversal and potentially the use of hash sets/maps for efficient lookups (O(n) solution).
How to answer:
Use a hash set. Iterate through the array. For each element x
, check if sum - x
exists in the set. If yes, a pair is found. Add x
to the set.
Example answer:
Create empty hash set seen
. For each num in array: complement = sum - num
. If complement
in seen
, return {num, complement} or print pair. Add num
to seen
.
23. Rotate an array by k positions.
Why you might get asked this:
Tests array manipulation, modulo arithmetic, and handling rotations efficiently (in-place if possible).
How to answer:
Method 1: Use an auxiliary array. Method 2: Reverse the entire array, then reverse the first k elements, then reverse the remaining elements. Method 3: Juggling algorithm (in-place, O(n)).
Example answer:
Using reversal: Reverse all elements. Reverse first k. Reverse remaining n-k. k = k % n; reverse(arr, 0, n-1); reverse(arr, 0, k-1); reverse(arr, k, n-1);
.
24. Find the missing number in a range.
Why you might get asked this:
Tests array processing, bit manipulation (XOR), or sum properties for efficient finding.
How to answer:
Option 1: Sum the numbers 0 to n and subtract the sum of the numbers in the array. Option 2: Use XOR. XOR all numbers from 0 to n with all numbers in the array. The result is the missing number.
Example answer:
Using XOR: missing = n; for i from 0 to n-1: missing = missing ^ i ^ arr[i]; return missing;
. Using sum: expectedsum = n*(n+1)/2; actualsum = sum(arr); return expectedsum - actualsum;
.
25. Implement quicksort or mergesort.
Why you might get asked this:
Classic sorting algorithms, fundamental to algorithms knowledge. Tests recursion (Mergesort, Quicksort) and partitioning (Quicksort) or merging (Mergesort).
How to answer:
Explain the divide-and-conquer strategy. Quicksort: pick pivot, partition, recurse. Mergesort: divide, recurse, merge. Discuss average/worst case time complexity.
Example answer:
Quicksort: quicksort(arr, low, high): if low < high: pivotidx = partition(arr, low, high); quicksort(arr, low, pivotidx-1); quicksort(arr, pivot_idx+1, high);
. Partition logic is key.
26. Explain OOP concepts: Inheritance, Polymorphism, Encapsulation, Abstraction.
Why you might get asked this:
Basic software engineering principles. Tests understanding of how these concepts promote code reusability, flexibility, organization, and manage complexity.
How to answer:
Define each concept and provide a simple real-world or code example for clarity. Inheritance: 'is-a' relationship, deriving classes. Polymorphism: 'many forms', method overriding/overloading. Encapsulation: Bundling data and methods, data hiding. Abstraction: Hiding complex details, showing only essentials.
Example answer:
Inheritance: Car is-a
Vehicle. Polymorphism: Shape has draw()
method, Circle/Square override it. Encapsulation: Class with private data, public getters/setters. Abstraction: Abstract class Vehicle
with abstract start()
method.
27. Compare abstract class and interface.
Why you might get asked this:
Tests understanding of OOP design choices and when to use each.
How to answer:
Highlight key differences: Abstract classes can have concrete methods and instance variables, interfaces only method signatures (pre-Java 8/9) and constants. A class can extend one abstract class but implement multiple interfaces. Abstract class for 'is-a' relationship with shared implementation, interface for 'can-do' capability.
Example answer:
Abstract Class: Partially implemented base class (e.g., AbstractAnimal
with eat()
method, abstract makeSound()
). Interface: Contract for behavior (e.g., Speakable
with speak()
method).
28. Find the lowest common ancestor (LCA) of two nodes in a binary tree.
Why you might get asked this:
Classic tree problem, often solved recursively or iteratively using parent pointers or paths.
How to answer:
Recursive: If node matches p or q, return node. If p and q are found in different subtrees, the current node is LCA. If both in same subtree, recurse into that subtree.
Example answer:
lca(root, p, q): if root is null or root==p or root==q return root. left = lca(root->left, p, q). right = lca(root->right, p, q). if left and right return root. return left ? left : right;
.
29. Find the longest common subsequence (LCS) of two strings.
Why you might get asked this:
Classic dynamic programming problem, testing table filling (tabulation) or memoization.
How to answer:
Use a 2D DP table dp[i][j]
representing the LCS length of the first i
characters of string1 and first j
characters of string2. Fill table based on character matches.
Example answer:
dp[i][j] = dp[i-1][j-1] + 1
if s1[i-1] == s2[j-1]. Else dp[i][j] = max(dp[i-1][j], dp[i][j-1])
. Base cases dp[0][j]=0, dp[i][0]=0. Result is dp[m][n].
30. Implement atoi (string to integer).
Why you might get asked this:
Tests string parsing, handling signs, whitespace, non-digit characters, and overflow conditions.
How to answer:
Trim whitespace, handle optional sign. Iterate through digits, converting characters to integer value. Check for overflow before adding each digit. Return 0 if invalid chars encountered early.
Example answer:
Skip leading whitespace. Check sign (+/-). Iterate while digit: num = num * 10 + digitval
. Check if num > INTMAX / 10 or (num == INTMAX / 10 and digitval > 7)
before adding. Handle overflow by returning INT_MAX/MIN.
Other Tips to Prepare for a Deloitte Coding Questions
Preparing effectively for Deloitte coding questions goes beyond just memorizing solutions. You need to build genuine problem-solving muscle and confidence. Consistent practice is key. Platforms like LeetCode, HackerRank, and CodeForces offer a wealth of problems across various difficulty levels and categories relevant to deloitte coding questions. Don't just solve problems; understand the underlying concepts and explore different approaches, analyzing their time and space complexity. As programming expert John Carmack once said, "The best way to prepare for a coding interview is to practice coding interviews."
Reviewing fundamental data structures and algorithms is crucial. Ensure you understand how they work, their trade-offs, and when to apply them. Practice coding on a whiteboard or shared document, as interviews often aren't in a full IDE. This helps improve your ability to write syntactically correct code and explain your logic step-by-step without relying on autocomplete. Consider using tools like Verve AI Interview Copilot to simulate interview scenarios and get feedback on your coding and communication style. The Verve AI Interview Copilot can provide realistic practice and help you refine your approach to deloitte coding questions. Another expert tip, often attributed to interview coaches, is to "think out loud." Explain your thought process, even false starts, as this shows interviewers how you approach problems. Utilizing resources like https://vervecopilot.com can offer structured practice sessions tailored to common interview patterns, including those for deloitte coding questions, allowing you to build confidence in a low-pressure environment before the real interview.
Frequently Asked Questions
Q1: What programming languages are allowed in Deloitte coding interviews?
A1: Typically, major languages like Java, Python, C++, or C# are accepted. Choose the one you are most comfortable and proficient in.
Q2: How much time is usually given for a coding question?
A2: Usually between 20-45 minutes per question, depending on complexity and the interview structure. Be mindful of time.
Q3: Should I aim for the most optimal solution immediately?
A3: No, start with a brute-force solution if it comes to mind, then discuss optimizing it. Explain your trade-offs (time vs. space).
Q4: What if I get stuck during a Deloitte coding question?
A4: Stay calm, think out loud, revisit the problem constraints, and ask clarifying questions or hints from the interviewer.
Q5: Are system design questions common for entry-level roles?
A5: Less common than DS/Algo, but basic concepts might be asked or a simpler design problem posed depending on the role.
Q6: How important is writing clean code in the interview?
A6: Very important. Code should be readable, well-structured, and handle edge cases. It reflects your professionalism.