Barclays Coding Questions and Answers
Barclays Coding Questions with Solutions
Barclays Coding Questions and Answers page will help you to get sample Coding Questions asked in the Online Assessments and Technical Interview of the Company for hiring the freshers from 2023, 2024 and 2025 Batch.
Further on this page you will get details on Job Profile, CTC Offered, complete recruitment process and some important point to remember about Barclays Recruitment Process.
About Barclays
Barclays is a leading global financial institution, that excels in providing an advanced range of innovative and client-focused services.
They offers advanced banking solutions, robust risk management strategies, and tailored investment products. With a distinguished team of industry professionals, Barclays maintains a strong presence in diverse sectors, including corporate banking, wealth management, and investment banking.
This organization has earned a strong reputation in the global financial world by consistently achieving great results. They are known for their dedication to providing excellent services and being a reliable and active participant in the financial industry.
Steps of Barclays Recruitment Process
There are 3 steps involved Barclays Recruitment Process, mentioned as follows:
- Round 1: Online Assessment [MCQs Based]
- Round 2: Technical Interview
- Round 3: HR Interview
Here we have mentioned some significant details of Barclays hiring process in the following tabular form:
Barclays | Related Information |
---|---|
Position : |
|
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
Cost to Company (CTC) | ~ ₹ 12 – 14 L.P.A |
Selection Process : |
|
Details of Online Assessment and Technical Interview of Barclays:
Rounds | Topics | Time |
---|---|---|
Online Assessment | MCQs + Coding | ~ 90 Minutes |
Technical Interview | Data Structures & Algorithms + Projects Overview | ~ 1 Hour |
- Section 1: MCQs based Section, consist of:
- Aptitude
- Reasoning
- Computer Science Engineering Fundamentals
- Section 2: Coding Section includes: Data Structures and Algorithms.
When preparing for the Technical interview with Barclays, it is important to be ready to discuss not only technical questions and advanced coding concepts but also your projects and internships, you have done during your graduation and post-graduation.
- Preview your projects.
- Highlight your role and contribution.
- Showcase your teamwork and collaboration skills.
- Make them aware of all Technicalities of your projects.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Sample Barclays Coding Questions with Solutions
Question 1 :
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<bits/stdc++.h> 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 Main { 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 2 : Elements of Matrix
Problem Statement
You are required to input the size of the matrix then the elements of matrix, then you have to divide the main matrix in two sub matrices (even and odd) in such a way that element at 0 index will be considered as even and element at 1st index will be considered as odd and so on. then you have sort the even and odd matrices in ascending order then print the sum of second largest number from both the matrices
Example
- enter the size of array : 5
- enter element at 0 index : 3
- enter element at 1 index : 4
- enter element at 2 index : 1
- enter element at 3 index : 7
- enter element at 4 index : 9
Sorted even array : 1 3 9
Sorted odd array : 4 7
7
#include<stdio.h> int main() { int arr[100]; int length, i, j, oddlen, evenlen, temp; int odd[50], even[50]; printf("Enter the length of the array: "); scanf("%d", &length); for (i = 0; i < length; i++) { printf("Enter element at index %d: ", i); scanf("%d", &arr[i]); } if (length % 2 == 0) { oddlen = length / 2; evenlen = length / 2; } else { oddlen = length / 2; evenlen = (length / 2) + 1; } for (i = 0; i < length; i++) { if (i % 2 == 0) { even[i / 2] = arr[i]; } else { odd[i / 2] = arr[i]; } } for (i = 0; i < evenlen - 1; i++) { for (j = i + 1; j < evenlen; j++) { if (even[i] > even[j]) { temp = even[i]; even[i] = even[j]; even[j] = temp; } } } for (i = 0; i < oddlen - 1; i++) { for (j = i + 1; j < oddlen; j++) { if (odd[i] > odd[j]) { temp = odd[i]; odd[i] = odd[j]; odd[j] = temp; } } } printf("\nSorted even array: "); for (i = 0; i < evenlen; i++) { printf("%d ", even[i]); } printf("\n"); printf("Sorted odd array: "); for (i = 0; i < oddlen; i++) { printf("%d ", odd[i]); } printf("\n"); printf("%d", even[evenlen - 2] + odd[oddlen - 2]); return 0; }
#include<bits/stdc++.h> using namespace std; int main () { int arr[100]; int length, i, j, oddlen, evenlen, temp, c, d; int odd[50], even[50]; cout << "enter the length of array : "; cin >> length; for (i = 0; i < length; i++) { cout << "Enter element at " << i << " index : "; cin >> arr[i]; } if (length % 2 == 0) { oddlen = length / 2; evenlen = length / 2; } else { oddlen = length / 2; evenlen = (length / 2) + 1; } for (i = 0; i < length; i++) // seperation of even and odd array { if (i % 2 == 0) { even[i / 2] = arr[i]; } else { odd[i / 2] = arr[i]; } } for (i = 0; i < evenlen - 1; i++) // sorting of even array { for (j = i + 1; j < evenlen; j++) { temp = 0; if (even[i] > even[j]) { temp = even[i]; even[i] = even[j]; even[j] = temp; } } } for (i = 0; i < oddlen - 1; i++) // sorting of odd array { for (j = i + 1; j < oddlen; j++) { temp = 0; if (odd[i] > odd[j]) { temp = odd[i]; odd[i] = odd[j]; odd[j] = temp; } } } cout << "\nSorted even array : "; // printing even array for (i = 0; i < evenlen; i++) { cout << even[i] << " "; } cout << "\n"; cout << "Sorted odd array : "; // printing odd array for (i = 0; i < oddlen; i++) { cout << odd[i] << " "; } cout << endl; cout << even[evenlen - 2] + odd[oddlen - 2]; // printing final result }
import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Main { public static void main (String[]args) { Scanner sc = new Scanner (System.in); System.out.print ("Enter size of array : "); int arrsize = sc.nextInt (); int[] main = new int[arrsize]; ArrayList < Integer > even = new < Integer > ArrayList (); ArrayList < Integer > odd = new < Integer > ArrayList (); System.out.println ("Enter " + arrsize + " Elements"); for (int i = 0; i < arrsize; i++) main[i] = sc.nextInt (); for (int i = 0; i < arrsize; i++) { if (i % 2 == 0) even.add (main[i]); else odd.add (main[i]); } Collections.sort (even); Collections.sort (odd); System.out.println ("Sorted even array "); for (int e:even) System.out.print (e + " "); System.out.println (); System.out.println ("sorted odd array "); for (int e:odd) System.out.print (e + " "); System.out.println (); int evensec = even.get (even.size () - 2); int oddsec = odd.get (odd.size () - 2); System.out.println ("Second Largest Element in Even List is:" + evensec); System.out.println ("Second Largest Element in Odd List is:" + oddsec); System. out.println ("Sum Of Second Largest Element Of Odd and Even List:" + (evensec + oddsec)); } }
array = [] evenArr = [] oddArr = [] n = int(input("Enter the size of the array:")) for i in range(0,n): number = int(input("Enter Element at {} index:".format(i))) array.append(number) if i % 2 == 0: evenArr.append(array[i]) else: oddArr.append(array[i]) evenArr = sorted(evenArr) print("Sorted Even Array:", evenArr[0:len(evenArr)]) oddArr = sorted(oddArr) print("Sorted Odd Array:", oddArr[0:len(oddArr)]) print(evenArr[1] + oddArr[1]) evenArr = sorted(evenArr) print("Sorted Even Array:", evenArr[0:len(evenArr)]) oddArr = sorted(oddArr) print("Sorted Odd Array:", oddArr[0:len(oddArr)]) print(evenArr[-2] + oddArr[-2])
Question 3 : Seating Arrangement in Exam Hall
Problem Statement :
Semester exams are going on for university students. Examiners noticed that a group of people are trying to cheat. They marked students of that group as ‘1’ and students of another group ( who are not cheating ) as ‘0’
We can reduce cheating by not allowing students from group 1 to sit together, means no two students from group 1 can sit together. Seatings are marked using above conditions. Your task is to give the seating placement of nth possibility Possibility order from 1 to 10 is given below
[1 10 100 101 1000 1001 1010 10000 10001 10010]
Sample input :
3 → number of test cases
4
6
9
Sample output :
101
1001
10001
Explanation :
4th possibility is 101
6th possibility is 1001
9th possibility is 10001
#include<bits/stdc++.h> using namespace std; int main() { int n, m, Max = 0; cin >> n; vector < int > v(n); vector < string > arr; for (int i = 0; i < n; i++) { cin >> v[i]; Max = max(Max, v[i]); } queue < string > q; q.push("1"); int i = 1; arr.push_back("1"); while (!q.empty()) { string a = q.front(); q.pop(); q.push(a + "0"); arr.push_back(a + "0"); i++; if (a[a.length() - 1] == '0') { q.push(a + "1"); arr.push_back(a + "1"); i++; } if (i > Max) break; } for (int i = 0; i < n; i++) { cout << arr[v[i] - 1] << endl; } }
import java.util.*; class Main { public static void possibilities(int n) { int c = 0; String b = ""; for (int i = 1; n != c; i++) { String s = Integer.toString(i, 2); if (!s.contains("11")) { c++; b = s; } } System.out.println(b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); int[] a = new int[tc]; for (int i = 0; i < tc; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < tc; i++) { possibilities(a[i]); } } }
t = int(input()) a = [] m = -1 m1 = -1 for i in range(t): m1 = int(input()) a.append(m1) m = max(m, m1) k2 = 2 n = m + 1 k1 = ["0"] * (n) k1[1] = "1" a1 = 1 while k2 < n: if k1[a1][-1] == "0": k1[k2] = k1[a1] + "0" k2 += 1 if k2 >= n: break k1[k2] = k1[a1] + "1" k2 += 1 if k2 >= n: break a1 += 1 elif k1[a1][-1] == "1": k1[k2] = k1[a1] + "0" k2 += 1 if k2 >= n: break a1 += 1 for i in a: print(k1[i])
Question 4 : Game Of Clicks [ R->Hard ]
Problem Statement :
Sahil watches TV all day and gets bored. He started playing this dumb game of identifying minimum number of inputs needed to reach a channel. As his cousin, you have to help him, but you live far from his house. So you decide to write a code that will ask Sahil for some inputs and give outputs respectively.
Here are the problems you need to keep in mind :
- There are 13 buttons on his remote: 10 buttons for the numbers (0-9) to form integers denoting respective channel index, “Up channel” button and “ Down channel” button for going i +1th channel and i-1th channel from i respectively, and a “Last viewed” button to see what’s the last channel before it.
- The number buttons allow you to jump directly to a specific channel (Ex: to go to channel 172 by typing 1,7,2).
- If the channel which you are in is ith and that is the max channel index possible, by Up channel, you will reach the first channel possible. Same goes for the down channel button. You can go to the highest channel possible if you go down from the lowest channel possible.
- Sahil can get from one channel to the next in one of the two ways.
- Sahil’s parents have set some parental control on some channels on Aniruth’s television. The “Up Channel “ and “Down buttons” buttons skip these channels as these channels are not viewable.
- Given a list of channels to view, the lowest channel, the highest channel, and a list of blocked channels, your program should return the minimum number of clicks necessary to get through all the shows that Anirudh would like to match.
Input Format :
- First line is the lowest Channel
- Second-line is the highest Channel
- Followed by a number of blocked channels B,
and the next B lines contain the actual blocked channels. - Followed by the number of Channels to view V, and the next V lines contain the actual channels to view.
Constraints :
- The lowest channel on the television will be greater than 0. and less than or equal to 10,000.
- The highest channel on the television will be greater than or equal to the lowest channel. and less than or equal to 10.000.
- The list of channels that are blocked on Anirudh’s television. All the channels in this list will be valid channels (greater than or equal to lowest channel, less than or equal 1 to highest channel). Duplicates may be Ignored. The blocked list can be a maximum of 40 channels.
- The sequence that Sahil must view contains between 1 and 50 elements. inclusive. All channels in this sequence are not in the blocked list and are between lowest channel and highest channel. Inclusive.
Sample Input 0:
1
20
2
18
19
5
15
14
17
11
17
Sample output 0:
8
#include<bits/stdc++.h> using namespace std; unordered_map < int, int > m; int l, u; int util(int a, int b) { if (a == b) return 0; if (m[a]) return util(a + 1, b); return 1 + util(a + 1, b); } int func(int b, int prev) { if (b < prev) return min(util(prev, u) + util(l, b) + 1, util(b, prev)); else return min(util(prev, b), util(l, b) + util(prev, u) + 1); } int main() { int flag = 0, ans = 0, prev, prev2; cin >> l >> u; int bn, b; cin >> bn; while (bn--) { cin >> b; m[b]++; } cin >> bn; while (bn--) { cin >> b; if (b > 9 && flag == 0) { ans += 2; flag++; prev = b; } else if (flag == 0) { ans += 1; flag++; prev = b; } else if (prev2 == b) { prev2 = prev; prev = b; ans++; } else { ans += min(b > 9 ? 2 : 1, func(prev, b)); prev2 = prev; prev = b; } } cout << ans; }
def prev(now, l, h, blocked): if now != l: if (now - 1) not in blocked: return now - 1 else: return prev(now - 1, l, h, blocked) else: if h not in blocked: return h else: return prev(h, l, h, blocked) def next(now, l, h, blocked): if now != h: if (now + 1) not in blocked: return now + 1 else: return next(now + 1, l, h, blocked) else: if l not in blocked: return l else: return next(l, l, h, blocked) def digits(n): count = 0 while n > 0: n = n // 10 count += 1 return count for i in range(2): if i == 0: l = int(input()) else: h = int(input()) b = int(input()) blocked = [] for i in range(b): blocked.append(int(input())) back = -1 now = -1 c = int(input()) k = 0 for i in range(c): n = int(input()) n1 = digits(n) if now == -1: now = n k += n1 continue if back == n: k += 1 back, now = now, back continue pf = 0 pb = 0 now1 = now prev1 = now for j in range(n1): if j == (n1 - 1): pf = n1 pb = n1 break else: now1 = next(now1, l, h, blocked) pf += 1 prev1 = prev(prev1, l, h, blocked) pb += 1 if now1 == n: break if prev1 == n: break k += pf back = now now = n print(k)
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int h = sc.nextInt(); int b = sc.nextInt(); ListblackList = new ArrayList<>(); for (int i = 0; i < b; i++) { blackList.add(sc.nextInt()); } int v = sc.nextInt(); Set validList = new HashSet<>(); for (int i = 0; i < v; i++) { int value = sc.nextInt(); if (!blackList.contains(value)) { validList.add(value); } } int totalLength = 0; for (int value : validList) { totalLength += String.valueOf(value).length(); } System.out.println(totalLength); } }
Question 05 : Duplicates
Problem statement : The principal has a problem with repetitions. Everytime someone sends the same email twice he becomes angry and starts yelling. His personal assistant filters the mails so that all the unique mails are sent only once, and if there is someone sending the same mail again and again, he deletes them. Write a program which will see the list of roll numbers of the student and find how many emails are to be deleted.
Sample Input:
6
1
3
3
4
3
3
Sample Output:
3
#include<bits/stdc++.h> using namespace std; map<int,int> m; int main() { int n,a,ans=0; cin>>n; while(n--) { cin>>a; m[a]++; if(m[a]>1) ans++; } cout<<ans; }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); TreeSet list=new TreeSet<>(); for(int i=0;i<n;i++) list.add(sc.nextInt()); System.out.println(Math.abs(n-list.size())); } }
def countDuplicate(numbers): c=0 for i in set(numbers): if numbers.count(i)>1: c+=numbers.count(i)-1 return c n=int(input()) numbers=[] for i in range(n): numbers.append(int(input())) print(countDuplicate(numbers))
FAQs on Barclays Coding Questions
Question 1: How long does Barclays recruitment process take?
Barclays generally takes 3 – 4 Weeks of time complete whole Recruitment Process.
Question 2: How many rounds are there in Barclays interview?
There are 2 Rounds of Interviews after clearing the Online Assessments of Barclays:
- Technical Interview
- HR Interview
Question 3: Does Barclays provide training?
Yes, Pre-Placement Training is always been a part of the Onboarding process of Barclays, as they want every new employee to understand the specific domain and job role.
Question 4: What is the salary of Barclays Graduate Analyst?
For Graduate Analyst or Graduate Analyst Trainee, salary offered by Barclays ranges between ₹ 12 – 14 L.P.A (aprrox.).
Question 5: Does Barclays hire freshers off campus?
Yes, Barclays always conducts Off-Campus drives every year in various Colleges and Universities. For more details get in touch with Training and Placement Officer of your Institution.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment