Ever wondered why so many students clear Deloitte’s aptitude test but stumble in the coding round? That’s because Deloitte doesn’t just test your programming, it tests your thinking structure.
The Deloitte Coding Round has evolved into one of the most competitive stages in campus recruitment. According to recent placement reports, over 65% of applicants lose marks here due to lack of pattern recognition and poor time management.
So, if you’re preparing for Deloitte and feel lost about what questions really appear and how to handle them smartly, this is where your preparation finally starts making sense.
By the end, you’ll know exactly what Deloitte expects, and how to deliver it with confidence.
TL;DR – Why You Shouldn’t Skip This Blog
If you are aiming to crack Deloitte’s Coding Round, this guide is your shortcut to clarity.
We’ve broken down real coding questions, explained patterns Deloitte repeats every year, and added expert-backed strategies to help you stand out.
Here’s what you’ll uncover:
- The complete Deloitte Coding Round syllabus and question types
- Solved coding examples from previous tests
- Step-by-step strategies used by successful candidates
- The truth behind how Deloitte evaluates logic, not language.
About Deloitte and HashedIn by Deloitte
Deloitte, or Deloitte Touche Tohmatsu Limited, is a top global professional services company. Deloitte operates in over 150 geographies and provides a range of services and products to help organizations manage big, complex, and often difficult business challenges and impacts, and make sustainable decisions and actions related to growth.
Key Business Areas
- Audit & Assurance:
Independent financial audits and assurance services to enhance transparency and trust. - Consulting:
Strategic, operational, technology, and human capital consulting to drive transformation and performance improvement. - Financial Advisory:
Support with mergers and acquisitions, restructuring, valuation, forensics, and other financial transactions. - Risk Advisory:
Identifying, assessing, and managing operational, technological, and regulatory risks. - Tax & Legal:
Providing comprehensive tax planning and compliance and legal advisory services for businesses and individuals.
Deloitte works with clients across diverse industries, including finance, healthcare, hospitality, and retail.
Relevance to Candidates
Deloitte is renowned for its commitment to innovation, professional development, and making an impact that matters. Employees benefit from a collaborative work culture, access to global clients, and opportunities to work on high-impact projects that shape industries and communities.
HashedIn by Deloitte
HashedIn by Deloitte, a market-leading subsidiary of Deloitte, (and one of many) has a practice with a focus on custom software solutions and digital transformation. HashedIn is known for working with clients in a extensive range of different sectors, including healthcare, banking, retail, and hospitality, and for creating creative, quick technical solutions for challenging issues.
Business Focus
- Custom Software Solutions:
Creating and implementing bespoke software products that meet the style, application, and delivery needs of clients. - Product Ideation and Development:
Supporting clients from concept to deployment with end-to-end product development. - Cloud Migration and DevOps Consulting:
Allowing companies to simplify development procedures and update their IT infrastructure. - User Experience Design:
Creating intuitive and impactful user interfaces for digital products.
Relevance to Candidates
HashedIn by Deloitte promotes a culture of unconventional thinking, teamwork, and continuous learning. Employees are encouraged to develop future-ready skills and contribute to innovative projects that drive business transformation for clients worldwide.
Importance of coding rounds in Deloitte Recruitment
The coding round is one of the most crucial stages in the Deloitte recruitment process, a true test of how well you can think, code, and solve problems under pressure.
Unlike basic aptitude tests, this round measures more than just syntax knowledge. It evaluates your logical reasoning, data structure mastery, and problem-solving efficiency. Questions are carefully designed to check your understanding of core programming concepts, from loops and recursion to arrays, strings, and algorithmic logic.
Being a global leader in consulting, audit, and technology, Deloitte looks for candidates who can blend analytical thinking with technical precision. Deloitte and HashedIn value anyone who can approach real-world problems and challenges not only with logic and structured development, but also applies rational, not fantasy, ways of building this knowledge. So if you are targeting Deloitte, learning how to master this coding round is not an option, it is a must!
In this guide, you’ll find everything you need to prepare effectively, including the top Deloitte coding questions, insights from previous National Level Assessments, and practical tips to strengthen your approach for the technical interview.
Concepts to Look in Deloitte Coding Topics
Usually, the interview starts with some personal questions like -
- Why this company and role?
- Tell me something about yourself that you have not mentioned on the CV?
After two or three such questions, the coding round starts, which is about 30 to 45 minutes. You will be given 3-5 coding questions and have to solve them in under 30 minutes.
Candidates can expect these topics in the Deloitte coding round:
Arrays
- Searching, sorting, and manipulation
- Subarrays and sub-sequences problems
Linked Lists
- Reversal, cycle detection, merging lists
- Problems involving n-th node from the end, deleting nodes
Stacks and Queues
- Parentheses matching, stack-based algorithms
- Implementing a queue using two stacks
Hashing
- HashMap, HashSet applications
- Frequency counting, anagram detection
Trees
- Binary Search Tree (BST) operations
- Tree traversals (pre-order, in-order, post-order)
- Height of tree, finding Lowest Common Ancestor (LCA)
Graphs
- Graph representation (adjacency list, matrix)
BFS and DFS
- Shortest path algorithms (Dijkstra, Bellman-Ford)
- Cycle detection in directed/undirected graphs
Eligibility Criteria and Job Roles at Deloitte and HashedIn
Before getting ready for the coding assessments at Deloitte, it is important to firstly understand the eligibility criteria and the available job positions. This will allow you to satisfy the basic qualification and get a clear understanding of the roles you are aiming for.
Eligibility Criteria
- Educational Qualifications:
Candidates with B.Tech (CSE, IT, ECE, EEE) or MCA degree are considered eligible. - Academic Performance:
Having an academic record is mandatory.Approximately 60 - 65% aggregate is expected for most positions. - Backlog Policy:
No live backlogs are permitted at the time of application. - Other Requirements:
Individuals in the last year of their degree and those who just graduated are typically allowed to apply. Candidates are expected to exhibit strong communication and have the essential technical basics.
Job Roles Available
- Software Engineering Associate (Internship):
This is an entry-level internship program for students or recent graduates to develop software, perform coding assessments, and work on real-world projects. - Software Engineer – I:
This is a full-time technical position that is generally offered after the successful completion of an internship. Typical work includes developing software, resolving issues, and working with cross-functional team. - Business Technology Analyst:
This job consists of interacting with clients, analyzing business processes, and making recommendations for technology solutions. This includes additional technical and consulting skills. - Analyst (Across Service Lines):
An introductory position in a variety of different service areas (Audit, Consulting, Risk Advisory, Financial Advisory, and Tax) where responsibilities may include data analysis or process improvement. - Consultant:
Advisor providing strategic and operational advice and implementation of solutions while engaging in client projects. It could include an emphasis on technology, operations, or transformation of the business. - Risk Analyst:
Focus area provides identification, assessment, and mitigation of risks for clients, which could include data analysis, process audits, and/or compliance. - Tax Consultant:
Works with clients on tax planning, compliance, and advisory services. Requires strong analytical and communication skills. - Other Roles:
Depending on business needs, Deloitte may offer positions in areas such as Human Resources, Operations, Financial Advisory, and more.
Salary and Benefits
- Starting CTC for Freshers:
Approximately INR 4,50,000 per annum. - Probation Period:
A one-year probation period is common for new joiners.
Note:
While coding assessments are primarily required for technical and engineering roles, Deloitte offers a wide range of opportunities across its service lines. Candidates interested in non-technical positions should review the specific requirements for each role.
Top Coding Questions Asked in Deloitte
Here are the coding questions asked in Deloitte:
Problem Statement 1: Given an array of integers, find the number of subarrays whose sum is odd. A subarray is defined as any contiguous portion of the array. You must count all subarrays where the sum of elements is odd.
Input
The first line contains an integer N (1 ≤ N ≤ 10^5), the size of the array.
The second line contains N integers, each between -1000 and 1000.
Output
Return the total number of subarrays with an odd sum.
Test Cases
C Program
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
int arr[N];
for(int i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
int odd_count = 0, even_count = 1, result = 0, prefix_sum = 0;
for(int i = 0; i < N; i++) {
prefix_sum += arr[i];
if (prefix_sum % 2 == 0)
result += odd_count;
else
result += even_count;
if (prefix_sum % 2 == 0)
even_count++;
else
odd_count++;
}
printf("%d\n", result);
return 0;
}
C++ Program
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> arr(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
int odd_count = 0, even_count = 1, result = 0, prefix_sum = 0;
for (int i = 0; i < N; i++) {
prefix_sum += arr[i];
if (prefix_sum % 2 == 0)
result += odd_count;
else
result += even_count;
if (prefix_sum % 2 == 0)
even_count++;
else
odd_count++;
}
cout << result << endl;
return 0;
}
Problem Statement 2: Given a string, find the length of the longest palindromic substring. A palindromic string reads the same forwards and backward. You must implement an efficient solution to find this substring.
Input
A string S with a length between 1 and 1000.
Output
Output the length of the longest palindromic substring.
Test Cases
| Input |
Output |
| Babad |
3 |
| cbbd |
2 |
C Program
#include <stdio.h>
#include <string.h>
#define MAX 1001
int max(int a, int b) {
return (a > b) ? a: b;
}
int expandAroundCenter(char *s, int left, int right) {
while (left >= 0 && right < strlen(s) && s[left] == s[right]) {
left--;
right++;
}
return right - left - 1;
}
int main() {
char s[MAX];
scanf("%s", s);
int len = strlen(s);
int max_len = 1;
for (int i = 0; i < len; i++) {
max_len = max(max_len, expandAroundCenter(s, i, i));
max_len = max(max_len, expandAroundCenter(s, i, i + 1));
}
printf("%d\n", max_len);
return 0;
}
C++ Program
#include <iostream>
#include <string>
using namespace std;
int max(int a, int b) {
return (a > b) ? a : b;
}
int expandAroundCenter(string s, int left, int right) {
while (left >= 0 && right < s.length() && s[left] == s[right]) {
left--;
right++;
}
return right - left - 1;
}
int main() {
string s;
cin >> s;
int len = s.length();
int max_len = 1;
for (int i = 0; i < len; i++) {
max_len = max(max_len, expandAroundCenter(s, i, i));
max_len = max(max_len, expandAroundCenter(s, i, i + 1));
}
cout << max_len << endl;
return 0;
}
Problem Statement 3: Given k sorted arrays, merge them into a single sorted array. Implement the solution using a min-heap or priority queue for optimal performance.
Input
- An integer k represents the number of arrays.
- k arrays of integers where each array is sorted.
Output
- Output the merged sorted array.
Test Cases
| Input |
Output |
|
|
1 2 3 4 5 6 7 8 9 |
|
|
1 2 3 4 5 6 |
C Program
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
typedef struct {
int value;
int row;
int col;
} Element;
int compare(const void *a, const void *b) {
return ((Element *)a)->value - ((Element *)b)->value;
}
int main() {
int k;
scanf("%d", &k);
int arr[k][1000], sizes[k];
for (int i = 0; i < k; i++) {
scanf("%d", &sizes[i]);
for (int j = 0; j < sizes[i]; j++) {
scanf("%d", &arr[i][j]);
}
}
Element heap[k];
int heap_size = 0;
for (int i = 0; i < k; i++) {
heap[heap_size].value = arr[i][0];
heap[heap_size].row = i;
heap[heap_size].col = 0;
heap_size++;
}
qsort(heap, heap_size, sizeof(Element), compare);
while (heap_size > 0) {
Element min = heap[0];
printf("%d ", min.value);
if (min.col + 1 < sizes[min.row]) {
heap[0].value = arr[min.row][min.col + 1];
heap[0].col = min.col + 1;
qsort(heap, heap_size, sizeof(Element), compare);
} else {
heap_size--;
for (int i = 0; i < heap_size; i++) {
heap[i] = heap[i + 1];
}
}
}
return 0;
}
C++ Program
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct Element {
int value;
int row;
int col;
};
class Compare {
public:
bool operator()(Element a, Element b) {
return a.value > b.value;
}
};
int main() {
int k;
cin >> k;
vector<vector<int>> arr(k);
vector<int> sizes(k);
for (int i = 0; i < k; i++) {
cin >> sizes[i];
arr[i].resize(sizes[i]);
for (int j = 0; j < sizes[i]; j++) {
cin >> arr[i][j];
}
}
priority_queue<Element, vector<Element>, Compare> minHeap;
for (int i = 0; i < k; i++) {
minHeap.push({arr[i][0], i, 0});
}
while (!minHeap.empty()) {
Element min = minHeap.top();
minHeap.pop();
cout << min.value << " ";
if (min.col + 1 < sizes[min.row]) {
minHeap.push({arr[min.row][min.col + 1], min.row, min.col + 1});
}
}
cout << endl;
return 0;
}
Problem Statement 4: Given an unsorted array of integers, find the kth largest element in the array. You need to solve the problem efficiently, without sorting the array, using a priority queue (min-heap) or quick select algorithm.
Input
- The first line contains two integers, N (size of array) and k.
- In the second line, there are N integers representing the array elements.
Output
- Output the kth largest element in the array.
Test cases
C Program
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b) {
return *(int*)b - *(int*)a;
}
int main() {
int N, k;
scanf("%d %d", &N, &k);
int arr[N];
for (int i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
qsort(arr, N, sizeof(int), compare);
printf("%d\n", arr[k-1]);
return 0;
}
C++ Program
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
int N, k;
cin >> N >> k;
vector<int> arr(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
priority_queue<int, vector<int>, greater<int>> minHeap;
for (int i = 0; i < N; i++) {
minHeap.push(arr[i]);
if (minHeap.size() > k) {
minHeap.pop();
}
}
cout << minHeap.top() << endl;
return 0;
}
₹ 49,000
Karthik was able to transform his career from a boring job to an
exciting job in software!
Talk to a career expert
Problem Statement 5: An inversion in an array is a pair of indices i and j such that i < j and arr[i] > arr[j]. Given an array, count the number of inversions in the array. You need to implement an efficient solution with a time complexity better than O(n^2).
Input
- The first line contains an integer N (1 ≤ N ≤ 10^5), the size of the array.
- In the second line, there are N integers representing the array elements.
Output
Return the count of inversions in the array.
Test Cases
C Program
#include <stdio.h>
int merge_and_count(int arr[], int temp[], int left, int right) {
int mid, inv_count = 0;
if (left < right) {
mid = (left + right) / 2;
inv_count += merge_and_count(arr, temp, left, mid);
inv_count += merge_and_count(arr, temp, mid + 1, right);
inv_count += merge(arr, temp, left, mid, right);
}
return inv_count;
}
int merge(int arr[], int temp[], int left, int mid, int right) {
int i = left, j = mid + 1, k = left, inv_count = 0;
while (i <= mid && j <= right) {
if (arr[i] <= arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
inv_count += (mid - i + 1);
}
}
while (i <= mid) {
temp[k++] = arr[i++];
}
while (j <= right) {
temp[k++] = arr[j++];
}
for (i = left; i <= right; i++) {
arr[i] = temp[i];
}
return inv_count;
}
int main() {
int N;
scanf("%d", &N);
int arr[N], temp[N];
for (int i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
printf("%d\n", merge_and_count(arr, temp, 0, N - 1));
return 0;
}
C++ Program
#include <iostream>
#include <vector>
using namespace std;
long long merge_and_count(vector<int>& arr, vector<int>& temp, int left, int right) {
long long inv_count = 0;
if (left < right) {
int mid = (left + right) / 2;
inv_count += merge_and_count(arr, temp, left, mid);
inv_count += merge_and_count(arr, temp, mid + 1, right);
inv_count += merge(arr, temp, left, mid, right);
}
return inv_count;
}
long long merge(vector<int>& arr, vector<int>& temp, int left, int mid, int right) {
int i = left, j = mid + 1, k = left;
long long inv_count = 0;
while (i <= mid && j <= right) {
if (arr[i] <= arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
inv_count += (mid - i + 1);
}
}
while (i <= mid) {
temp[k++] = arr[i++];
}
while (j <= right) {
temp[k++] = arr[j++];
}
for (int i = left; i <= right; i++) {
arr[i] = temp[i];
}
return inv_count;
}
int main() {
int N;
cin >> N;
vector<int> arr(N), temp(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
cout << merge_and_count(arr, temp, 0, N - 1) << endl;
return 0;
}
Problem Statement 6: Given an unsorted array of integers, find the length of the longest increasing subsequence (LIS). An increasing subsequence is a subsequence where all elements are sorted in increasing order. Implement an efficient solution.
Input
- The first line contains an integer N (1 ≤ N ≤ 10^5).
- In the second line, there are N integers representing the array elements.
Output
Return the length of the longest increasing subsequence.
C Program
#include <stdio.h>
#include <stdlib.h>
int max(int a, int b) {
return (a > b) ? a : b;
}
int LIS(int arr[], int N) {
int lis[N];
lis[0] = 1;
for (int i = 1; i < N; i++) {
lis[i] = 1;
for (int j = 0; j < i; j++) {
if (arr[i] > arr[j]) {
lis[i] = max(lis[i], lis[j] + 1);
}
}
}
int max_len = 0;
for (int i = 0; i < N; i++) {
max_len = max(max_len, lis[i]);
}
return max_len;
}
int main() {
int N;
scanf("%d", &N);
int arr[N];
for (int i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
printf("%d\n", LIS(arr, N));
return 0;
}
C++ Program
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int LIS(const vector<int>& arr, int N) {
vector<int> lis(N, 1);
for (int i = 1; i < N; i++) {
for (int j = 0; j < i; j++) {
if (arr[i] > arr[j]) {
lis[i] = max(lis[i], lis[j] + 1);
}
}
}
return *max_element(lis.begin(), lis.end());
}
int main() {
int N;
cin >> N;
vector<int> arr(N);
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
cout << LIS(arr, N) << endl;
return 0;
}
Problem Statement 7: Given an array arr[] of size n, the task is to find the maximum sum of a subarray that can be obtained by deleting at most one element from the array. This is an extension of Kadane’s Algorithm.
Input
- An integer n represents the size of the array.
- An array arr[] of n integers.
Output
Return the maximum sum of a subarray that can be obtained by deleting at most one element.
Test Cases
| Input |
Output |
| arr[] = {1, -2, 0, 3} |
4 |
| arr[] = {1, -2, -2, 3} |
3 |
C Program
#include <stdio.h>
#include <limits.h>
int maxSumAfterOneDeletion(int arr[], int n) {
int max_sum = arr[0], sum_with_deletion = 0, prev_sum = 0;
for (int i = 0; i < n; i++) {
prev_sum = prev_sum + arr[i];
sum_with_deletion = sum_with_deletion + arr[i];
if (sum_with_deletion < prev_sum) {
sum_with_deletion = prev_sum;
}
if (prev_sum < 0) {
prev_sum = 0;
}
max_sum = (max_sum > sum_with_deletion) ? max_sum : sum_with_deletion;
}
return max_sum;
}
int main() {
int arr[] = {1, -2, 0, 3};
int n = sizeof(arr) / sizeof(arr[0]);
printf("%d\n", maxSumAfterOneDeletion(arr, n));
return 0;
}
C++ Program
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int maxSumAfterOneDeletion(vector<int>& arr) {
int n = arr.size();
int max_sum = arr[0], prev_sum = 0, sum_with_deletion = 0;
for (int i = 0; i < n; i++) {
prev_sum = max(arr[i], prev_sum + arr[i]);
sum_with_deletion = max(sum_with_deletion + arr[i], prev_sum);
max_sum = max(max_sum, sum_with_deletion);
}
return max_sum;
}
int main() {
vector<int> arr = {1, -2, 0, 3};
cout << maxSumAfterOneDeletion(arr) << endl;
return 0;
}
Problem Statement 8: Given a singly linked list, you need to reverse it. Modify the list in place, without using any extra space (except for a few pointers). Implement a function that reverses the entire list and returns the new head of the list.
Input
Output
| Input |
Output |
| a1 -> 2 -> 3 -> 4 -> NULL |
4 -> 3 -> 2 -> 1 -> NULL |
| 5 -> 10 -> 15 -> NULL |
15 -> 10 -> 5 -> NULL |
C Program
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
void reverse(struct Node** head) {
struct Node *prev = NULL, *current = *head, *next = NULL;
while (current != NULL) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
void printList(struct Node* head) {
while (head != NULL) {
printf("%d -> ", head->data);
head = head->next;
}
printf("NULL\n");
}
int main() {
struct Node* head = NULL;
struct Node* newNode;
newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = 1;
newNode->next = head;
head = newNode;
newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = 2;
newNode->next = head;
head = newNode;
printList(head);
reverse(&head);
printList(head);
return 0;
}
C++ Program
#include <iostream>
using namespace std;
struct Node {
int data;
Node* next;
};
void reverse(Node*& head) {
Node *prev = nullptr, *current = head, *next = nullptr;
while (current != nullptr) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
head = prev;
}
void printList(Node* head) {
while (head != nullptr) {
cout << head->data << " -> ";
head = head->next;
}
cout << "NULL" << endl;
}
int main() {
Node* head = nullptr;
Node* newNode = new Node{1, head};
head = newNode;
newNode = new Node{2, head};
head = newNode;
printList(head);
reverse(head);
printList(head);
return 0;
}
₹ 49,000
Karthik was able to transform his career from a boring job to an
exciting job in software!
Talk to a career expert
Problem Statement 9: Write a function to generate the first n Fibonacci numbers.
Input
- The user is prompted to enter the number n, which represents how many Fibonacci numbers should be generated.
Output
- The program generates and displays the first n Fibonacci numbers.
| Input |
Output |
| 5 |
0 1 1 2 3 |
| 3 |
0 1 1 |
C Program
#include <stdio.h>
// Function to generate the first n Fibonacci numbers
void generateFibonacci(int n) {
int first = 0, second = 1, next;
if (n <= 0) {
printf("Enter a positive integer.\n");
return;
}
printf("Fibonacci series: ");
// Print the first Fibonacci number
printf("%d ", first);
// Print the second Fibonacci number
if (n > 1) {
printf("%d ", second);
}
// Generate and print the rest of the Fibonacci series
for (int i = 3; i <= n; i++) {
next = first + second;
printf("%d ", next);
first = second;
second = next;
}
printf("\n");
}
int main() {
int n;
printf("Enter the number of Fibonacci terms to generate: ");
scanf("%d", &n);
generateFibonacci(n);
return 0;
}
C++ Program
#include <iostream>
using namespace std;
// Function to generate the first n Fibonacci numbers
void generateFibonacci(int n) {
int first = 0, second = 1, next;
if (n <= 0) {
cout << "Enter a positive integer." << endl;
return;
}
cout << "Fibonacci series: ";
// Print the first Fibonacci number
cout << first << " ";
// Print the second Fibonacci number
if (n > 1) {
cout << second << " ";
}
// Generate and print the rest of the Fibonacci series
for (int i = 3; i <= n; i++) {
next = first + second;
cout << next << " ";
first = second;
second = next;
}
cout << endl;
}
int main() {
int n;
cout << "Enter the number of Fibonacci terms to generate: ";
cin >> n;
generateFibonacci(n);
return 0;
}
Problem Statement 10: Write a function to check if a number is prime. Also, How can a number be expressed as a sum of two prime numbers?
Input
- The user is prompted to enter a number num to check if it's prime.
Output
- The program checks if the entered number is prime and displays the result.
| Input |
Output |
| 29 |
29 is a prime number |
| 18 |
18 is not a prime number |
C Program
#include <stdio.h>
#include <stdbool.h>
// Function to check if a number is prime
bool isPrime(int n) {
if (n <= 1) {
return false; // 0 and 1 are not prime numbers
}
// Check for factors from 2 to sqrt(n)
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false; // n is divisible by i, so it's not prime
}
}
return true;
}
// Function to check if a number can be expressed as a sum of two prime numbers
void checkPrimeSum(int n) {
printf("Checking if %d can be expressed as a sum of two primes:\n", n);
for (int i = 2; i <= n / 2; i++) {
if (isPrime(i) && isPrime(n - i)) {
printf("%d = %d + %d\n", n, i, n - i);
return; // Found a pair, exit the function
}
}
printf("%d cannot be expressed as the sum of two prime numbers.\n", n);
}
int main() {
int num;
// Check if the number is prime
printf("Enter a number to check if it's prime: ");
scanf("%d", &num);
if (isPrime(num)) {
printf("%d is a prime number.\n", num);
} else {
printf("%d is not a prime number.\n", num);
}
// Check if the number can be expressed as the sum of two primes
printf("Enter a number to check if it can be expressed as the sum of two primes: ");
scanf("%d", &num);
checkPrimeSum(num);
return 0;
}
Problem Statement 11: You are developing a software feature for a plagiarism detection tool. One of the detection methods involves checking whether the content in two documents is simply a rearrangement of the same set of words, which could indicate potential plagiarism.
Write a function that takes two sentences as input and checks if they are sentence anagrams, meaning the sentences contain exactly the same words (ignoring order and case).
Input
- The user is prompted to enter two sentences. The program will check if the two sentences are anagrams by removing punctuation and converting the characters to lowercase.
Output
- The program checks if the two sentences are anagrams and displays the result.
| Input |
Output |
|
|
The sentences are anagrams. |
|
|
The sentences are not anagrams. |
C Program
#include <stdio.h>
#include <string.h>
#include <ctype.h>
// Function to clean and sort the words in a sentence
void cleanAndSort(char *sentence, char *result) {
int j = 0;
int len = strlen(sentence);
// Remove punctuation and convert to lowercase
for (int i = 0; i < len; i++) {
if (isalpha(sentence[i]) || isspace(sentence[i])) { // Keep letters and spaces
result[j++] = tolower(sentence[i]); // Convert to lowercase }
}
result[j] = '\0'; // Null-terminate the string
// Sort the cleaned string
for (int i = 0; i < j - 1; i++) {
for (int k = i + 1; k < j; k++) {
if (result[i] > result[k]) {
char temp = result[i];
result[i] = result[k];
result[k] = temp;
}
}
}
}
// Function to check if two sentences are anagrams
int areSentencesAnagrams(char *sentence1, char *sentence2) {
char cleaned1[1000], cleaned2[1000];
// Clean and sort the sentences
cleanAndSort(sentence1, cleaned1);
cleanAndSort(sentence2, cleaned2);
// Compare the cleaned and sorted versions
return strcmp(cleaned1, cleaned2) == 0;
}
int main() {
char sentence1[1000], sentence2[1000];
// Input two sentences
printf("Enter the first sentence: ");
fgets(sentence1, sizeof(sentence1), stdin);
printf("Enter the second sentence: ");
fgets(sentence2, sizeof(sentence2), stdin);
// Remove newline character from fgets input
sentence1[strcspn(sentence1, "\n")] = '\0';
sentence2[strcspn(sentence2, "\n")] = '\0';
// Check if sentences are anagrams
if (areSentencesAnagrams(sentence1, sentence2)) {
printf("The sentences are anagrams.\n");
} else {
printf("The sentences are not anagrams.\n");
}
return 0;
}
C++ Program
#include <iostream>
#include <cstring>
#include <cctype>
#include <algorithm> // For std::sort
// Function to clean and sort the words in a sentence
void cleanAndSort(const char *sentence, char *result) {
int j = 0;
int len = strlen(sentence);
// Remove punctuation and convert to lowercase
for (int i = 0; i < len; i++) {
if (isalpha(sentence[i]) || isspace(sentence[i])) { // Keep letters and spaces
result[j++] = tolower(sentence[i]); // Convert to lowercase
}
}
result[j] = '\0'; // Null-terminate the string
// Sort the cleaned string
std::sort(result, result + j); // Using C++'s built-in sort
}
// Function to check if two sentences are anagrams
bool areSentencesAnagrams(const char *sentence1, const char *sentence2) {
char cleaned1[1000], cleaned2[1000];
// Clean and sort the sentences
cleanAndSort(sentence1, cleaned1);
cleanAndSort(sentence2, cleaned2);
// Compare the cleaned and sorted versions
return strcmp(cleaned1, cleaned2) == 0;
}
int main() {
char sentence1[1000], sentence2[1000];
// Input two sentences
std::cout << "Enter the first sentence: ";
std::cin.getline(sentence1, sizeof(sentence1));
std::cout << "Enter the second sentence: ";
std::cin.getline(sentence2, sizeof(sentence2));
// Check if sentences are anagrams
if (areSentencesAnagrams(sentence1, sentence2)) {
std::cout << "The sentences are anagrams.\n";
} else {
std::cout << "The sentences are not anagrams.\n";
}
return 0;
}
Quick Summary
- Deloitte’s coding round primarily tests problem-solving and logical thinking through questions on arrays, strings, recursion, and data structures. Most problems focus on pattern recognition, optimization, and clean code logic rather than complex syntax.
- Typical question types include string manipulation, array-based computations, search/sort algorithms, and basic recursion problems.
- Students who practice LeetCode easy-to-medium level questions and focus on time and space complexity usually perform best.
Bottom Line: Deloitte values clarity, logic, and structured thinking, not just the right output.
Conclusion
To sum up, the Deloitte Coding Round is not solely an assessment of your programming abilities; it will assess how well you are able to analyze, optimize, and communicate that logic within the context of code. The questions are intended to evaluate your comprehension of the fundamental ideas of DSA, your effectiveness in solving problems, and your capacity to act logically under pressure.
If you are able to comprehend the patterns present in Deloitte’s coding questions (variables, arrays, strings, recursion, sorting, etc.), it will assist you greatly. The syntax is not the most important for Deloitte; they are very interested in whether there is clarity of logic, a structured approach and evidence of calculator-reasoning in your thinking process.
Points to Remeber
- Focus on core problem types: arrays, strings, recursion, and algorithms.
- Prioritize clean, optimized code and readability over brute-force solutions.
- Use platforms like LeetCode, HackerRank, and CodeStudio for practice.
- Time yourself, Deloitte’s coding round often values speed + accuracy.
₹ 49,000
Karthik was able to transform his career from a boring job to an
exciting job in software!
Talk to a career expert
Frequently Asked Questions
1. Does Deloitte have coding questions?
In technical interviews, Deloitte does indeed ask coding questions, particularly for positions involving software development. These inquiries usually center on data structures, algorithms, problem-solving, and occasionally system architecture.
2. Which company has the hardest coding interview questions?
The difficulty of coding interview questions can vary depending on the role, but some of the companies known for having particularly challenging coding interviews include:
These companies often ask complex algorithmic and data structure questions, as well as design problems.
3. Does Deloitte ask DSA questions?
Yes, Deloitte does ask questions about data structures and algorithms (DSA). These are a key part of the interview process for technical roles, focusing on problem-solving skills using different data structures like arrays, trees, graphs, and algorithms such as sorting, searching, and dynamic programming.
4. Is the Deloitte interview easy to crack?
The difficulty can be dependent on the role you are interviewing for, the preparation you put into it and your experience. A Deloitte technical interview will not be as grueling or intimidating as some of the tech giants such as Google or Facebook, but you will still need to demonstrate an adequate understanding and an approach to solving coding/DSA problems. With an effective approach to preparation and a good grasp of key concepts, you can probably make the process easier.
5. What are some common Deloitte coding questions for freshers?
Freshers can expect basic questions on arrays, strings, and searching algorithms such as binary search and linear search.
6. How can I prepare for Deloitte NLA coding questions?
The purpose of the Deloitte National Level Assessment coding question challenge is to hone your advanced algorithms and problem-solving strategies in competitive coding environments. Make sure to practice them and go over the NDA questions from the previous year.
7. What topics and question types are commonly covered in the Deloitte Coding Exam?
Deloitte’s coding assessments focus on:
- Arrays and strings (e.g., subarrays, searching, sorting, manipulation)
- Data structures like linked lists (including problems similar to the "class monitor" or linked list momentum questions)
- Stacks and queues (parentheses matching, stack-based algorithms)
- Hashing (frequency counting, anagram detection)
- Trees and graphs (basic traversals, shortest paths)
- Recursion and dynamic programming
- Advanced coding questions may involve optimization or pattern recognition
8. Can I retake the coding assessment if I don’t clear it?
Retakes are generally not allowed immediately. You may reapply in the next recruitment cycle if not selected.