Deloitte NLA Coding Questions and Answers
Deloitte NLA Coding Questions with Solutions
On the Deloitte NLA Coding Questions and Answers page, you will find out all the details related to the Hiring process of Deloitte including Coding Questions asked in NLA ( National Level Assessment ) and Technical Interview, Job Profile, Salary, Job Location, and other related details.
About Deloitte
Deloitte, formally known as Deloitte Touche Tohmatsu Limited is a leading global services provider company. They provide services in consulting, financial advisory, tax management, risk management, audit, and assurance.
Deloitte is also having a Subsidiary, Deloitte US – India Consulting, which works under the Deloitte US Organization providing the same services as Deloitte US Organization gives.
About Deloitte NLA Recruitment Process
This Hiring process of Deloiite National Level Assessment consists of following steps :
- Online Assessment [ Aptitude, Verbal and Technical Based ]
- Technical and HR Interview
Note – We have a dedicated page for Deloitte NLA Coding Questions and Answers, but if you want exact “What type of questions asked in Deloitte NLA Coding Round”, scroll down and fulfill your dream 🙂
We have mentioned further details of Deloitte NLA Recruitment Process in following Tabular Form for a particular Job Profile
Points | Related Informations |
---|---|
Position : | Analyst Trainee |
Course : |
|
Eligibility Criteria / Academic Qualification Required : | Minimum 60% or equivalent CGPA of 6.5 and above |
Cost to Company (CTC) | Rs 4,00,000 /- P.A |
Selection Process : |
|
Pattern of Deloitte NLA Recruitment Exam :
Deloitte National Level Assessment has a 90-minute time limit and is divided into 4 sections, which are mentioned below :
Topics | Number of Questions | |
---|---|---|
Language Skills (English) | 10 MCQs + 3 FUBs | |
General Aptitude | 12 Reasoning + 10 Quants | |
Technical MCQs | 30 Questions | |
Coding Questions | 2 Questions |
Deloitte NLA Coding Questions and Answers
Question 1
Problem Statement –
A chocolate factory is packing chocolates into the packets. The chocolate packets here represent an array of N number of integer values. The task is to find the empty packets(0) of chocolate and push it to the end of the conveyor belt(array).
Example 1 :
N=8 and arr = [4,5,0,1,9,0,5,0].
There are 3 empty packets in the given set. These 3 empty packets represented as O should be pushed towards the end of the array
Input :
8 – Value of N
[4,5,0,1,9,0,5,0] – Element of arr[O] to arr[N-1],While input each element is separated by newline
Output:
4 5 1 9 5 0 0 0
Example 2:
Input:
6 — Value of N.
[6,0,1,8,0,2] – Element of arr[0] to arr[N-1], While input each element is separated by newline
Output:
6 1 8 2 0 0
#include <stdio.h> int main() { int n, j = 0; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[j]); if (a[j] != 0) { j++; } } for (int i = 0; i < j; i++) { printf("%d ", a[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main () { int n, j = 0; cin >> n; int a[n] = { 0 }; for (int i = 0; i < n; i++) { cin >> a[j]; if (a[j] != 0) { j++; } } for (int i = 0; i < n; i++) { cout << a[i] << " "; } }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i< n;i++) arr[i]=sc.nextInt(); int count=0; for(int i=0;i< n;i++) if(arr[i]!=0) arr[count++]=arr[i]; for(int i=count;i < n;i++) arr[i]=0; for(int i=0;i< n;i++) System.out.print(arr[i]+" "); } }
n = int(input()) # Read the size of the list L = list(map(int, input().split())) # Read the list of integers j = 0 i=0 # Move non-zero elements to the front for i in range(n): if L[i] != 0: L[j] = L[i] j += 1 # Fill remaining positions with zeros for i in range(j, n): L[i] = 0 # Print the list with non-zero elements followed by zeros print(*L)
Question 2
Problem Statement –
Joseph is learning digital logic subject which will be for his next semester. He usually tries to solve unit assignment problems before the lecture. Today he got one tricky question. The problem statement is “A positive integer has been given as an input. Convert decimal value to binary representation. Toggle all bits of it after the most significant bit including the most significant bit. Print the positive integer value after toggling all bits”.
Constraints-
1<=N<=100
Example 1:
Input :
10 -> Integer
Output :
5 -> result- Integer
Explanation:
Binary representation of 10 is 1010. After toggling the bits(1010), will get 0101 which represents “5”. Hence output will print “5”.
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; // Convert to binary and toggle bits int result = ~N & ((1 << (int(log2(N)) + 1)) - 1); cout << result << endl; return 0; }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); // Find the number of bits required to represent N int bitLength = (int) (Math.log(N) / Math.log(2)) + 1; // Toggle the bits and mask out the higher bits int result = (~N) & ((1 << bitLength) - 1); System.out.println(result); } }
def main(): N = int(input()) # Find the number of bits required to represent N bit_length = N.bit_length() # Toggle the bits and mask out the higher bits result = ~N & ((1 << bit_length) - 1) print(result) if __name__ == "__main__": main()
Question 3
You are given a function,
int findCount(int arr[], int length, int num, int diff);
The function accepts an integer array ‘arr’, its length and two integer variables ‘num’ and ‘diff’. Implement this function to find and return the number of elements of ‘arr’ having an absolute difference of less than or equal to ‘diff’ with ‘num’.
Note: In case there is no element in ‘arr’ whose absolute difference with ‘num’ is less than or equal to ‘diff’, return -1.
Example:
Input:
- arr: 12 3 14 56 77 13
- num: 13
- diff: 2
Output:
3
Explanation:
Elements of ‘arr’ having absolute difference of less than or equal to ‘diff’ i.e. 2 with ‘num’ i.e. 13 are 12, 13 and 14.
#include<bits/stdc++.h> using namespace std; int findCount (int n, int arr[], int num, int diff) { int count = 0; for (int i = 0; i < n; ++i) { if (abs (arr[i] - num) <= diff) { count++; } } return count > 0 ? count : -1; } int main () { int n; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; } int num; cin >> num; int diff; cin >> diff; cout << findCount (n, arr, num, diff); }
#include <stdio.h> #include <stdlib.h> int findCount (int n, int arr[], int num, int diff) { int count = 0; for (int i = 0; i < n; ++i) { if (abs (arr[i] - num) <= diff) { count++; } } return count > 0 ? count : -1; } int main () { int n; scanf ("%d", &n); int arr[n]; for (int i = 0; i < n; ++i) { scanf ("%d", &arr[i]); } int num; scanf ("%d", &num); int diff; scanf ("%d", &diff); printf ("%d\n", findCount (n, arr, num, diff)); return 0; }
def findCount(n, arr, num, diff): count=0 for i in range(n): if(abs(arr[i]-num)<=diff): count+=1 if count: return count return 0 n=int(input()) arr=list(map(int,input().split())) num=int(input()) diff=int(input()) print(findCount(n, arr, num, diff))
import java.util.*; class Main { public static int findCount (int arr[], int length, int num, int diff) { int count = 0; for (int i = 0; i < length; i++) { if (Math.abs (num - arr[i]) <= diff) count++; } return count > 0 ? count : -1; } public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt (); int num = sc.nextInt (); int diff = sc.nextInt (); System.out.println (findCount (arr, n, num, diff)); } }
Question 4
Implement the following Function
def differenceofSum(n. m)
The function accepts two integers n, m as arguments Find the sum of all numbers in range from 1 to m(both inclusive) that are not divisible by n. Return difference between sum of integers not divisible by n with sum of numbers divisible by n.
Assumption:
- n>0 and m>0
- Sum lies between integral range
Example
Input
n:4
m:20
Output
90
Explanation
- Sum of numbers divisible by 4 are 4 + 8 + 12 + 16 + 20 = 60
- Sum of numbers not divisible by 4 are 1 +2 + 3 + 5 + 6 + 7 + 9 + 10 + 11 + 13 + 14 + 15 + 17 + 18 + 19 = 150
- Difference 150 – 60 = 90
Sample Input
n:3
m:10
Sample Output
19
#include <iostream> using namespace std; int differenceofSum (int n, int m) { int i, sum1 = 0, sum2 = 0; for (i = 1; i <= m; i++) { if (i % n == 0) { sum1 = sum1 + i; } else { sum2 = sum2 + i; } } if (sum2 > sum1) return sum2 - sum1; else return sum1 - sum2; } int main () { int n, m; int result; cin >> n; cin >> m; result = differenceofSum (n, m); cout << result; return 0; }
#include<stdio.h> int differenceofSum (int n, int m) { int i, sum1 = 0, sum2 = 0; for (i = 1; i <= m; i++) { if (i % n == 0) { sum1 = sum1 + i; } else { sum2 = sum2 + i; } } if (sum2 > sum1) return sum2 - sum1; else return sum1 - sum2; } int main () { int n, m; int result; scanf ("%d", &n); scanf ("%d", &m); result = differenceofSum (n, m); printf ("%d", result); return 0; }
n = int(input()) m = int(input()) sum1 = 0 sum2 = 0 for i in range(1,m+1): if i % n == 0: sum1+=i else: sum2+=i print(abs(sum2-sum1))
import java.util.*; class Solution { public static int differenceOfSum (int m, int n) { int sum1 = 0, sum2 = 0; for (int i = 1; i <= m; i++) { if (i % n == 0) sum1 = sum1 + i; else sum2 = sum2 + i; } return Math.abs (sum1 - sum2); } public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int m = sc.nextInt (); System.out.println (differenceOfSum (m, n)); } }
Question 5
Airport security officials have confiscated several item of the passengers at the security check point. All the items have been dumped into a huge box (array). Each item possesses a certain amount of risk[0,1,2]. Here, the risk severity of the items represent an array[] of N number of integer values. The task here is to sort the items based on their levels of risk in the array. The risk values range from 0 to 2.
Example :
Input :
7 -> Value of N
[1,0,2,0,1,0,2]-> Element of arr[0] to arr[N-1], while input each element is separated by new line.
Output :
0 0 0 1 1 2 2 -> Element after sorting based on risk severity
Example 2:
input : 10 -> Value of N
[2,1,0,2,1,0,0,1,2,0] -> Element of arr[0] to arr[N-1], while input each element is separated by a new line.
Output :
0 0 0 0 1 1 1 2 2 2 ->Elements after sorting based on risk severity.
Explanation:
In the above example, the input is an array of size N consisting of only 0’s, 1’s and 2s. The output is a sorted array from 0 to 2 based on risk severity.
#include<stdio.h> void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sortArray(int arr[], int size) { int low = 0, mid = 0, high = size - 1; while (mid <= high) { if (arr[mid] == 0) { swap(&arr[low], &arr[mid]); low++; mid++; } else if (arr[mid] == 1) { mid++; } else { swap(&arr[mid], &arr[high]); high--; } } } int main() { int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sortArray(a, n); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } return 0; }
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
int a[n];
for(int i=0;i< n;i++) cin>>a[i];
int l=0,m=0,h=n-1;
while(m<=h)
{
if(a[m]==0) swap(a[l++],a[m++]);
else if(a[m]==1) m++;
else swap(a[m],a[h--]);
}
for(int i=0;i< n;i++) cout<< a[i]<<" ";
}
import java.util.*; class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i< n;i++) arr[i]=sc.nextInt(); int countZero=0,countOne=0,countTwo=0; for(int i=0;i< n;i++) { if(arr[i]==0) countZero++; else if(arr[i]==1) countOne++; else if(arr[i]==2) countTwo++; } int j =0; while(countZero >0) { arr[j++]=0; countZero--; } while(countOne >0) { arr[j++]=1; countOne--; } while(countTwo >0) { arr[j++]=2; countTwo--; } for(int i=0;i < n;i++) System.out.print(arr[i]+" "); } }
n = int(input()) arr = [] for i in range(n): arr.append(int(input())) for i in sorted(arr): print(i, end=" ")
FAQs related to Deloitte NLA Coding Questions
Question 1: What kind of roles are available at Deloitte in India?
Deloitte offers a variety of roles across different domains like Audit, Consulting, Financial Advisory, Risk advisory, Tax and related services.
Question 2: Does Deloitte asks coding questions in there Recruitment Process?
Yes, Deloitte asks coding questions in there National Level Assessment and Technical Interview.
Question 3: Is Registration Process is still going on?
Yes, The registration process is still going on, You can apply directly via Deloitte Registration Page.