Deloitte Previous Year Coding Questions 2025
Deloitte is one of the "Big Four" professional services firms, offering a wide range of services including audit, tax, consulting, financial advisory, and technology solutions. With a global presence in over 150 countries and a workforce of over 450,000 professionals, Deloitte is renowned for its innovative approach, client-centric solutions, and commitment to fostering talent. For students and professionals, Deloitte offers exciting career opportunities in areas such as technology, consulting, analytics, and cybersecurity, making it a top choice for those seeking impactful roles in a dynamic environment.
Deloitte’s Hiring Process
Deloitte’s recruitment process is designed to identify candidates with strong technical, analytical, and interpersonal skills. The process typically includes the following stages:
- Online Application: Candidates apply through Deloitte’s official job portals, submitting resumes and relevant details.
- Online Assessment: For technical roles, candidates often take the Deloitte National Level Assessment (NLA), which tests quantitative ability, logical reasoning, language skills, and technical/coding proficiency.
- Group Discussion (Optional): Some roles involve a group discussion to evaluate communication and teamwork skills.
- Technical Interview: Candidates are assessed on programming skills, problem-solving, and domain knowledge, often involving coding questions or case studies.
- HR Interview: Focuses on behavioral questions, cultural fit, and career aspirations.
- Offer and Onboarding: Successful candidates receive an offer, followed by onboarding and training programs.
The process varies slightly depending on the role (e.g., technology, consulting, or analytics) and location (e.g., India, US, or global offices). Preparation for the NLA and technical interviews is crucial, as they often include coding challenges similar to those listed below.
Why Join Deloitte?
- Global Exposure: Work on diverse projects with clients across industries and geographies.
- Learning Opportunities: Access to Deloitte University and extensive training programs.
- Career Growth: Clear career paths with opportunities for leadership and specialization.
- Innovative Culture: Engage with cutting-edge technologies like AI, cloud, and data analytics.
Resources for Preparation
To help candidates prepare for Deloitte’s hiring process, below is a curated list of official and external resources:
Official Careers & Job Portals
- Deloitte Global Career Search
- Deloitte Global Careers Page
- Deloitte India Careers
- Deloitte South Asia Careers
- Deloitte US Careers
- Deloitte Job Application Portal
Students & Internship Programs
- Internships at Deloitte – Global Overview
- Deloitte US Internships
- Deloitte US-India Students Page
- Campus Connect Opportunities – Deloitte India
- Deloitte US Students & Early Careers
- Student & Graduate Job Portal
Recruitment Process & Application Tips
Additional Preparation Resources
- Interview Tips – Deloitte Careers
- Case Interview Preparation
- Behavioral Interview Tips
- TargetJobs – Deloitte Interview Prep Guide
- Reddit: Deloitte Interview Tips
- Quora: How to Clear Deloitte Interviews
Lets Code Resources
- ✅ Free Mock Test
- ✅ ATS Score Checker & Resume Optimization
- ✅ Previous Year Questions (PYQs)
- ✅ Roadmaps
- ✅ Interview Questions
- ✅ Interview Experience
- ✅ Resume Templates
- ✅ Free Study Notes
- ✅ Free Placement Material Drive Link
Problem 1: Class Monitor
In an engineering college, the HOD needs to select a class monitor from n students based on their JEE ranks. The HOD maintains a register and updates it by cutting the name of the current monitor and writing a new name if a student with a lower rank is encountered. Given the sequence of ranks observed by the HOD, determine how many names are cut from the register.
Input Format
- First line: A single integer N, the number of visits by the HOD.
- Second line: N space-separated integers representing the ranks observed during each visit.
Output Format
- A single integer representing the number of times a name is cut from the register.
Constraints
- 1 ≤ N ≤ 10^9
- 1 ≤ rank ≤ 10000
Example
Input:
5
3 5 2 1 4
Output:
2
Problem 2: Corona for Computer
A computer virus with n spikes eats the n least significant bits (LSB) of the binary representation of numbers. Given an array of N integers and the number of spikes n, compute the resulting values after the virus removes the n LSBs from each number.
Input Format
- First line: A single integer N, the number of integers in the array.
- Second line: N space-separated integers representing the array V.
- Third line: A single integer n, the number of spikes in the virus.
Output Format
- N space-separated integers representing the array after the virus removes n LSBs from each number.
Constraints
- 1 ≤ N ≤ 10^5
- 0 ≤ V[i] ≤ 10^9
- 0 ≤ n ≤ 30
Example
Input:
3
7 10 5
2
Output:
1 2 1
Problem 3: Help of Prepsters
Given two integers n and k, find the count of numbers less than n that have exactly k set bits (1s) in their binary representation.
Input Format
- First line: Two space-separated integers n and k.
Output Format
- A single integer representing the count of numbers less than n with exactly k set bits.
Constraints
- 1 ≤ n ≤ 10000
- 1 ≤ k ≤ 10
Example
Input:
10 2
Output:
3
Problem 4: Momentum LinkedList
A linked list represents n particles, each with a mass and velocity. All particles move in the same direction. Compute the total momentum of the system, where momentum for each particle is calculated as mass × velocity.
Input Format
- First line: A single integer n, the number of nodes in the linked list.
- Next n lines: Two space-separated integers representing the mass and velocity of each particle.
Output Format
- A single integer representing the total momentum of the system.
Constraints
- 1 ≤ n ≤ 10000
- 1 ≤ mass, velocity ≤ 100
Example
Input:
3
2 3
4 2
1 5
Output:
15
Problem 5: Lazy String
Anish, tasked with writing the winner’s name in a game, writes the lexicographically smallest longest common subsequence (LCS) of two given names to minimize edits. Given two names, determine the lexicographically smallest LCS.
Input Format
- First line: A string S1 representing the first name (all capital letters).
- Second line: A string S2 representing the second name (all capital letters).
Output Format
- A single string representing the lexicographically smallest longest common subsequence.
Constraints
- 1 ≤ |S1|, |S2| ≤ 100
- Strings contain only uppercase letters (A-Z).
Example
Input:
ABCD
ACBD
Output:
ABD
Problem 6: Unique Substrings / Permutation Count
Given a string that may contain repeated characters, generate all unique permutations of the string and output them in lexicographical order.
Input Format
- A single string S.
Output Format
- Multiple lines, each containing a unique permutation of the input string in lexicographical order.
Constraints
- 1 ≤ |S| ≤ 8
- S contains only lowercase letters (a-z).
Example
Input:
aab
Output:
aab
aba
baa
Problem 7: String Rotation Check
Determine if one string is a rotation of another. A string S2 is a rotation of S1 if S2 can be obtained by moving some characters from the start of S1 to its end without changing their order.
Input Format
- First line: A string S1.
- Second line: A string S2.
Output Format
- A single string: "Yes" if S2 is a rotation of S1, otherwise "No".
Constraints
- 1 ≤ |S1|, |S2| ≤ 10^5
- S1 and S2 contain only lowercase letters (a-z).
Example
Input:
abcd
cdab
Output:
Yes
Problem 8: Sum of Digits Until Single Digit
Given a number, repeatedly sum its digits until a single-digit result is obtained.
Input Format
- A single integer num.
Output Format
- A single integer representing the final single-digit result.
Constraints
- 1 ≤ num ≤ 10^9
Example
Input:
123
Output:
6
Problem 9: Special Character Removal & Word Count
Given a messy sentence containing alphabetic characters, spaces, and special characters, remove all non-alphabetic characters (except spaces) and count the number of valid words in the resulting string.
Input Format
- A single string S representing the messy sentence.
Output Format
- A single integer representing the number of valid words.
Constraints
- 1 ≤ |S| ≤ 10^5
- S contains alphanumeric characters, spaces, and special characters.
Example
Input:
Hello!! World@ How# Are$ You
Output:
5
Problem 10: Number of Subarrays with Odd Sum
Given an array of integers, count the number of contiguous subarrays whose sum is odd.
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the number of subarrays with an odd sum.
Constraints
- 1 ≤ N ≤ 10^5
- -1000 ≤ arr[i] ≤ 1000
Example
Input:
3
1 2 3
Output:
4
Problem 11: Longest Palindromic Substring
Given a string, find the length of the longest substring that is a palindrome (reads the same forwards and backward).
Input Format
- A single string S.
Output Format
- A single integer representing the length of the longest palindromic substring.
Constraints
- 1 ≤ |S| ≤ 1000
- S contains only lowercase letters (a-z).
Example
Input:
babad
Output:
3
Problem 12: Merge K Sorted Arrays
Given k sorted arrays, merge them into a single sorted array using an efficient approach.
Input Format
- First line: An integer k, the number of arrays.
- Next k lines: Each line starts with an integer m (size of the array), followed by m space-separated integers representing a sorted array.
Output Format
- A single line containing space-separated integers representing the merged sorted array.
Constraints
- 1 ≤ k ≤ 100
- 1 ≤ m ≤ 1000
- -10^4 ≤ arr[i] ≤ 10^4
Example
Input:
2
3 1 3 5
2 2 4
Output:
1 2 3 4 5
Problem 13: Kth Largest Element in an Array
Given an unsorted array of integers, find the kth largest element in the array using an efficient approach (e.g., priority queue or quick select).
Input Format
- First line: Two space-separated integers N (array size) and k.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the kth largest element.
Constraints
- 1 ≤ N ≤ 10^5
- 1 ≤ k ≤ N
- -10^4 ≤ arr[i] ≤ 10^4
Example
Input:
5 2
3 1 4 5 2
Output:
4
Problem 14: Count Inversions in an Array
Given an array, count the number of inversions, where an inversion is a pair of indices (i, j) such that i < j and arr[i] > arr[j]. Use an efficient approach (e.g., merge sort).
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the number of inversions.
Constraints
- 1 ≤ N ≤ 10^5
- -10^9 ≤ arr[i] ≤ 10^9
Example
Input:
4
3 2 4 1
Output:
4
Problem 15: N Digit Prime Numbers with Most Frequent Digit
Given two integers N and D, find all N-digit prime numbers where the digit D is the most frequent digit in the number.
Input Format
- First line: Two space-separated integers N and D.
Output Format
- A single line containing space-separated N-digit prime numbers where D is the most frequent digit, in ascending order. If none exist, output -1.
Constraints
- 1 ≤ N ≤ 5
- 0 ≤ D ≤ 9
Example
Input:
2 1
Output:
11 13 17 19
Problem 16: Copycat in Exam
Rahul copies text in an exam but avoids detection by interchanging the positions of letters in words while keeping the letters constant. Given a string, output the string with the letters of each word reversed.
Input Format
- A single string S.
Output Format
- A single string with the letters of each word reversed.
Constraints
- 1 ≤ |S| ≤ 10^5
- S contains only lowercase letters and spaces.
Example
Input:
hello world
Output:
olleh dlrow
Problem 17: Maximum Subarray Sum
Given an array of integers, find the maximum sum of any contiguous subarray. The subarray must contain at least one element.
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the maximum sum of any contiguous subarray.
Constraints
- 1 ≤ N ≤ 10^5
- -10^4 ≤ arr[i] ≤ 10^4
Example
Input:
6
-2 1 -3 4 -1 2
Output:
6
Problem 18: String Anagram Check
Given two strings, determine if they are anagrams of each other. Two strings are anagrams if they contain the same characters with the same frequencies, ignoring spaces and case.
Input Format
- First line: A string S1.
- Second line: A string S2.
Output Format
- A single string: "Yes" if the strings are anagrams, otherwise "No".
Constraints
- 1 ≤ |S1|, |S2| ≤ 10^5
- S1 and S2 contain only lowercase letters and spaces.
Example
Input:
listen
silent
Output:
Yes
Problem 19: Minimum Path Sum in Grid
Given a grid of non-negative integers, find the minimum path sum from the top-left to the bottom-right corner. You can only move right or down.
Input Format
- First line: Two space-separated integers M and N, representing the grid dimensions.
- Next M lines: N space-separated integers representing the grid.
Output Format
- A single integer representing the minimum path sum.
Constraints
- 1 ≤ M, N ≤ 100
- 0 ≤ grid[i][j] ≤ 1000
Example
Input:
3 3
1 3 1
2 5 2
3 4 1
Output:
12
Problem 20: Valid Parentheses
Given a string containing only parentheses characters ( '(', ')', '{', '}', '[', ']' ), determine if the string is valid. A string is valid if every open parenthesis is closed in the correct order.
Input Format
- A single string S.
Output Format
- A single string: "Yes" if the string is valid, otherwise "No".
Constraints
- 1 ≤ |S| ≤ 10^4
- S contains only '(', ')', '{', '}', '[', ']'.
Example
Input:
{[]}
Output:
Yes
Problem 21: Find Missing Number
Given an array containing N distinct numbers taken from the range 0 to N, find the missing number in the sequence.
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the missing number.
Constraints
- 1 ≤ N ≤ 10^5
- 0 ≤ arr[i] ≤ N
Example
Input:
4
0 1 3 4
Output:
2
Problem 22: Reverse Linked List
Given a singly linked list, reverse the list and return the new head node.
Input Format
- First line: An integer N, the number of nodes in the linked list.
- Second line: N space-separated integers representing the linked list nodes.
Output Format
- A single line containing N space-separated integers representing the reversed linked list.
Constraints
- 1 ≤ N ≤ 10^4
- -10^4 ≤ node value ≤ 10^4
Example
Input:
5
1 2 3 4 5
Output:
5 4 3 2 1
Problem 23: Two Sum
Given an array of integers and a target sum, find two numbers in the array that add up to the target. Return their indices (0-based).
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
- Third line: An integer T, the target sum.
Output Format
- Two space-separated integers representing the indices of the two numbers that sum to T.
Constraints
- 2 ≤ N ≤ 10^4
- -10^9 ≤ arr[i], T ≤ 10^9
Example
Input:
4
2 7 11 15
9
Output:
0 1
Problem 24: Longest Increasing Subsequence
Given an array of integers, find the length of the longest strictly increasing subsequence.
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
Output Format
- A single integer representing the length of the longest increasing subsequence.
Constraints
- 1 ≤ N ≤ 10^3
- -10^6 ≤ arr[i] ≤ 10^6
Example
Input:
7
10 9 2 5 3 7 101
Output:
4
Problem 25: Graph Cycle Detection
Given an undirected graph, determine if it contains a cycle. The graph is represented as an adjacency list.
Input Format
- First line: Two space-separated integers V and E, representing the number of vertices and edges.
- Next E lines: Two space-separated integers u and v, representing an edge between vertices u and v.
Output Format
- A single string: "Yes" if the graph contains a cycle, otherwise "No".
Constraints
- 1 ≤ V ≤ 10^3
- 0 ≤ E ≤ 10^4
- 0 ≤ u, v < V
Example
Input:
4 4
0 1
1 2
2 3
3 1
Output:
Yes
Problem 26: Rotate Array
Given an array of integers, rotate the array to the right by k steps. If k is larger than the array length, handle it appropriately.
Input Format
- First line: An integer N, the size of the array.
- Second line: N space-separated integers representing the array.
- Third line: An integer k, the number of steps to rotate.
Output Format
- A single line containing N space-separated integers representing the rotated array.
Constraints
- 1 ≤ N ≤ 10^5
- -10^9 ≤ arr[i] ≤ 10^9
- 0 ≤ k ≤ 10^9
Example
Input:
7
1 2 3 4 5 6 7
3
Output:
5 6 7 1 2 3 4
Join Telegram group for any doubts & discussions!