HSBC Coding Questions
Top HSBC Coding Questions
In this page you will find out all the insights on HSBC Hiring Process. Including Important Dates, Job Description, Eligibility Criteria, Online Aptitude and Coding Questions and also Company – Specific Assessments.About HSBC
HSBC is the world’s largest banking and financial services company. They globally provide various services like: Commercial and Personal Banking, Global Marketing and Banking Services. In 1987, HSBC gave the greatest contribution in development of Banking Industry of India by providing India’s First ATM .
HSBC Recruitment Process
The Online Assessment consists of 2 sections :
- Aptitude + Technical Assessment
- Coding Test (After clearing the 1st Round)
We have even tabulated some more information for your reference and understanding.
Points | Important Informations |
---|---|
Position : |
|
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
Cost to Company (CTC) |
|
Selection Process : |
|
Joining Location : | Pune / Hyderabad / Bangalore [Work From Office] |
Details of HSBC Online Assessment :
Topics | Time | |
---|---|---|
Aptitude + Techinal Questions | 75 Minutes | |
Coding Test | 30 Minutes |
More details related to this JobPost
- Required Strong fundamentals in Software Development Engineering with proficiency at least in 1 Object Oriented Programming Language such as Python, Java, etc.
- Should have command in OS like Android, Linux & Databases like RDBMS and no – SQL.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Sample HSBC Coding Questions With Solutions
Question 1 : Weird Terminal
Problem Statement :
Here is a weird problem in Susan’s terminal. He can not write more than two words each line, if she writes more than two, it takes only 2 words and the rest are not taken. So she needs to use enter and put the rest in a new line. For a given paragraph, how many lines are needed to be written in Susan’s terminal?
Input Format:
A string as the text to input in the terminal
Output Format:
Number of lines written.
Constraints:
Number of words <=10^7
Sample Input:
How long do you have to sit dear ?
Sample Output:
4
Explanation:
The writing will be:
How long
Do you
Have to
Sit dear ?
#include<bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int ans = 0; istringstream ss(s); while (ss) { string word; int flag = 0; ss >> word; if (word == "") break; for (int i = 0; i < word.length(); i++) if (!isalpha(word[i])) { if (i != 0) { if (i == word.length() - 1) { if (word[i] == ',' || word[i] == '.' || word[i] == ';' || word[i] == ':' || word[i] == '?' || word[i] == '!') continue; } else if (word[i] == '.' && word[i + 1] != '.') { flag++; break; } else if (word[i] == '-' && isalpha(word[i + 1])) continue; else { flag++; break; } } else { flag++; break; } } if (flag == 0) { ans++; //cout <<word<<" "<<word.length()<<endl; } } cout << floor((ans - 1) / 2) + 1; }
s=input() n=len(s) s1='' for i in range(n): if s[i]=='-': s1+='' continue if s[i]=='.' or s[i]=='!' or s[i]==',' or s[i]=='?': s1+=' ' continue else: s1+=s[i] a=list(s1.split()) c=0 for i in a: i1=0 for j in i: if not ((ord(j)>=65 and ord(j)<=90) or (ord(j)>=97 and ord(j)<=122)): i1=1 break if i1==0: c+=1 print((c-1)//2 +1)
Question 2 : Password Hacker
Problem statement :
Elliot made a KeyLogger for his friend Romero, so that he can see the passwords of his friend. Keylogger is a software that can tell you the buttons pressed in the keyboard without the consent of the user, and hence unethical. Elliot made it to hack Romero’s passwords. The one problem is, Romero writes the passwords in lowercase characters only, and the keylogger only takes the values of the keys. Like, for a it takes 1, for b 2, and for z 26. For a given number Elliot produces all combinations of passwords in a dictionary and starts a dictionary based password attack. For a given number, print all the possible passwords in a lexicographic order.
Input Format:
One line, denoting the value given by the keylogger
Output Format:
All possible combinations of keyloggers in new lines are lexicographically ordered.
Constraints:
2<=Number of digit in input<=1000
Sample Input:
1234
Sample Output:
abcd
axd
Mcd
Explanation:
For 12, you can take 1,2 that is ab, or you can take l.
#include<bits/stdc++.h> using namespace std; string ss; vector < string > v; void fun(int i, string s) { //cout<< i<< s<< endl; if (i == ss.length()) { v.push_back(s); return; } if (i > ss.length()) return; if (ss[i] == '0') return; char c = 'a' + (ss[i] - '1'); fun(i + 1, s + c); if (i != s.length() - 1) if (ss[i] < '3' && ss[i + 1] < '7') { int a = (ss[i] - '1' + 1), b = (ss[i + 1] - '0'); c = ('a' + (10 * a + b - 1)); //cout<< a<< b<< endl; fun(i + 2, s + c); } } int main() { cin >> ss; fun(0, ""); sort(v.begin(), v.end()); for (auto i: v) cout << i << endl; }
Question 3 : Find the sequence sum
Problem statement :
Rohit loves to play with sequences so he has given you a sequence to solve. To prove to him that you are a good coder, you accept the challenge. Find the sum of the sequence. Given three integers i,j,k find i+(i+1)+(i+2)+(i+3)…j+(j-1)+(j-2)+(j-3)……..k
CONSTRAINTS:
- -108<=i,j,k<=108
- i,k<=j
SAMPLE CASE0 :
0 → i=0
5 → j=5
-1 → k=-1
SAMPLE OUTPUT 0:
24
EXPLANATION 0:
0+1+2+3+4+5+4+3+2+1+0-1 =24
import java.util.*; public class Sequence { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i = sc.nextInt(); int j = sc.nextInt(); int k = sc.nextInt(); float n, s1, s2; n = Math.abs(j - i) + 1; s1 = (n / 2) * (2 * i + (n - 1)); n = Math.abs(k - (j - 1)) + 1; s2 = (n / 2) * (2 * (j - 1) - (n - 1)); System.out.println((int)(s1 + s2)); } }
i=int(input()) j=int(input()) k=int(input()) n=abs(j-i)+1 s1=(n/2)*(2*i+(n-1)) n=abs(k-(j-1))+1 s2=(n/2)*(2*(j-1)-(n-1)) print(int(s1+s2))
Question 4 :Picking Tickets
Problem statement :
There are consecutive lighthouses present in the x axis of a plane.You are given n, which represents the the number of light position and x coordinate array which represent the position of the lighthouses.You have to find maximum lighthouses which have absolute difference less than or equal to 1 between adjacent numbers.
CONSTRAINTS
- 1<=n<105
- 1<=tickets[i]<=109
SAMPLE CASE 0:
SAMPLE INPUT 0:
4 → tickets[] size=4
4 → tickets[] =[4,13,2,3]
13
2
3
SAMPLE OUTPUT 0:
3
EXPLANATION
There are 2 subsequences of tickets that contain consecutive integers when sorted. {2,3,4} and {13} . These sequences has m values as 3 and 1 respectively . return maximum value of m which is 3.
import java.util.*; public class ConsecutiveNumbers { 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(); Arrays.sort(arr); int count = 0; int max = -1; for (int i = 0; i < n - 1; i++) { if ((arr[i + 1] - arr[i] == 0) || (arr[i + 1] - arr[i] == 1)) count++; else { if (count + 1 > max) max = count + 1; count = 0; } } System.out.println(max); } }
n=int(input()) arr=[] for i in range(n): arr.append(int(input())) arr.sort() c=0 count=[] for i in range(n-1): if(abs(arr[i]-arr[i+1])==0 or abs(arr[i]-arr[i+1])==1): c+=1 else: count.append(c+1) c=0 count.append(c+1) print(max(count))
Question 5 :Fantasy Premier League
Problem statement :
Ramesh loves to bet and also loves football, so he created a fantasy football team in FPL. He chose Rashford in his team. You are given a string in which each index denotes a match and it consists of characters: Y, G, A. G means goal scored and the player is awarded 4 points, for A 3 points, and for every Y, 1 point is deducted.
Calculate the points scored by rashford
Constraints:
- 0<n<105
Sample case 0:
Sample input 0:
EHH → erica=”EHH”
EME → bob=”EME”
Sample output 0:
Erica
Explanation 0:
Erica’s score is , 1+5+5=11
Bob’s score is , 1+3+1=5
So Erica is the winner
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here int t; t = 1; while (t--) { string erica, bob; cin >> erica >> bob; int erica_score = 0, bob_score = 0; for (int i = 0; i < erica.length(); i++) { if (erica[i] == 'E') erica_score += 1; else if (erica[i] == 'M') erica_score += 3; else erica_score += 5; } for (int i = 0; i < bob.length(); i++) { if (bob[i] == 'E') bob_score += 1; else if (bob[i] == 'M') bob_score += 3; else bob_score += 5; } if (erica_score > bob_score) { cout << "Erica\n"; } else if (erica_score < bob_score) { cout << "Bob\n"; } else { cout << "Tie\n"; } } return 0; }
import java.util.*; public class CoderFriends { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String erica = sc.next(); String bob = sc.next(); int ericaScore = 0; int bobScore = 0; for (int i = 0; i < erica.length(); i++) { if (erica.charAt(i) == 'E') ericaScore = ericaScore + 1; else if (erica.charAt(i) == 'M') ericaScore = ericaScore + 3; else if (erica.charAt(i) == 'H') ericaScore = ericaScore + 5; } for (int i = 0; i < bob.length(); i++) { if (bob.charAt(i) == 'E') bobScore = bobScore + 1; else if (bob.charAt(i) == 'M') bobScore = bobScore + 3; else if (bob.charAt(i) == 'H') bobScore = bobScore + 5; } if (bobScore == ericaScore) System.out.println("Tie"); else if (bobScore > ericaScore) System.out.println("Bob"); else System.out.println("Erica"); } } }
erica=input() bob=input() erica_score=erica.count("E")+erica.count("M")*3+erica.count("H")*5 bob_score=bob.count("E")+bob.count("M")*3+bob.count("H")*5 if(erica_score==bob_score): print("Tie") elif(erica_score>bob_score): print("Erica") else: print("Bob")
FAQs on HSBC Coding Questions with Solutions
Question 1: What type of questions are asked in the HSBC Online Assessment ?
HSBC Online Assessment consists of an online test which has aptitude and technical questions and a coding test.
Question 2: Is HSBC exam difficult?
HSBC exam is a little tricky, but with proper practice and preparation it can be cracked easily by anyone.
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