# PB junior Recruitment Test Solutions

Note : If you find any solutions here similar to what you people had written previously during the test then check them properly you might have missed to add suttle things like long long , and so on.

• Your mail might have given you 0 for MCQ’s this was a bug from hacerearth’s. we did cross check with the original scores and they turned out to be correct ones.

Credits :
Solutions in c++ provided by : Nishant Mohan
Solutions in python provided by : Yash Nandwana
Editorialist : Calan Pereira

MCQ’s :

• Mobile Dev :
1. How to upgrade SQlite the database from a lower version to higher version in android SQlite?
• Using Intent
• Using helper class (Correct)
• Using cursor
• using firebase
1. How to pass data between activities in android?
• Content Provider
• Pubspec Yaml

Blockchain :

1. P2P stand for ___________.
• Private to Public
• Public to Private
• Peer to Peer (Correct answer)
• Proof to Proof
1. The process of creating new bitcoins is known as __________.
• Financing
• Sourcing
• Proof of stake

DSA :

1. what kind of searching method is used to find a maxima or minima in a unimodal function?
• Linear Search
• Binary Search
• exhaustive search
1. Which Datastructure uses the FIFO technique.
• Stack
• Heap

General Reasoning :

1. x and y are real numbers such that 2log(x – 2y) = log x + log y. What is the value of x/y ?
• 1
• Either (a) or (b)
• None of these
1. The sequence 1, 2, 4, 5, 7, 9, 10, 12, 14, 16, 17,…. has one odd number followed by the next two even numbers, then the next three odd numbers followed by the next four even numbers and so on. What is the 2003rd term of the sequence?
• 3953
• 3940
• 3950

Maths (AI/ML):

1. What does a neuron compute?
• A neuron computes an activation function followed by a linear function (z = Wx + b)
• b) A neuron computes a linear function (z = Wx + b) followed by an activation function (Correct answer)
• A neuron computes a function g that scales the input x linearly (Wx + b)
• A neuron computes the mean of all features before applying the output to an activation function
1. Which parameter determines the size of the improvement step to take on each iteration of Gradient Descent?
• epoch
• batch size
• regularization parameter

DBMS / Networking / Security :

1. Which of the following is generally used for performing tasks like creating the structure of the relations, deleting relation?
• DML(Data Manipulation Language)

• Query

• Relational Schema

• DDL(Data Definition Language) (Correct answer)

1. Code Injection attacks can be handled by
• Server side rendering
• Client side rendering
• Encrypted communication channel

OS / Hardware :

1. An Arduino is an example of a …?
• Microprocessor

• Microcomputer

• System On Chip (SoC).

1. Rank the following storage drives in terms of speed (lowest to highest).
• NVMe SSD < SATA HDD < SATA SSD

• SATA HDD < SATA SSD < NVMe SSD (Correct answer)

• SATA SSD < NVMe SSD < SATA HDD

• SATA HDD < NVMe SSD < SATA SSD.

Linux :

1. When is the sudo command not required?
• When the user is running as root.

• after running the sudo su command successfully.

• Both are true. (Correct answer)

• None are true.

1. Linux is …
• a UNIX system.

• a UNIX like system. (Correct answer)

• a UNIX descendent system.

• a UNIX system predecessor.

Devops :

1. Which of the following is not a pure containerization service.
• cri-o

• lxc

• ansible

1. Which of the following is false about functions of load balancers?
• Distributes client requests or network load efficiently across multiple servers

• Ensures high availability and reliability by sending requests only to servers that are online

• Provides the flexibility to add or subtract servers as demand dictates

• None of these (Correct answer)

Backend :

1. GraphQL is a
• HTTP API

• REST API

• SOAP API

• None of these (Correct answer)

Front End :

1. The element used as a container for some text is defined as

• div

• container

• textarea

Coding Problem :

1. Find Duplicate

Solution in cpp :

#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;

int arr[n];

map<int,int>mapm;

int ans = -1;

for(int i = 0; i < n ; i++){

cin >> arr[i];

mapm[arr[i]]++;

if(mapm[arr[i]]==2){ans = arr[i];}

}
cout << ans << endl;
}

Solution in python :

n = int(input())
a = sorted(list(map(int, input().split())))
ans = None
for i in range(n - 1):
if a[i] == a[i + 1]:
ans = a[i]
break
print(ans)
1. Find the right combination

C++ Solution :

#include<bits/stdc++.h>
using namespace std;
int main(){
long long x, p;
cin >> x >> p;
cout << p-x+1 << endl;
return 0;
}

Solution in python :

n, p = map(int, input().split())
print(p - n + 1)
1. In The Middle

Solution in c++ :

#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
int arr[n];
for(int i = 0; i < n ; i++){
cin >> arr[i];
}
sort(arr,arr+n);
int mid = (n+1)/2;
mid--;
cout << arr[mid] << endl;
}

Solution in python :

n = int(input())
a = list(map(int, input().split()))
a.sort()
print(a[n // 2])
1. orz Tree

Solution in c++ :

#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
string s = "orz";
int k = 0;
for(int i = 0; i < n; i++){
k = n-i;
k--;
// k counts the spaces we have to print befor printing the "orz.." string!
while(k--){cout << " ";}
cout << s << endl;
s += "orz";
} return 0;
}

Solution in python :

n = int(input())
for i in range(1, n + 1):
print((n - i) * " " + i * "orz")
1. Mersenne Prime Candidate:

Solution in c++ :

#include<bits/stdc++.h>
using namespace std;
int main(){
long long x; cin >> x;
long long mul =1;
bool cond = false;
// x+2 because if mul can be x+1 then also we can get our answer!
while(mul<= x+2){
if(mul-1==x){cond = true;}
mul = 2*mul;
}
if(cond){cout << "YES";} else{cout << "NO";}
cout << endl;
}

Solution in python :

n = int(input())
if not ((n + 1) & n):
print("YES")
else:
print("NO")
1. Manja

Solution in c++ :

#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n; cin >> n;
long long int arr[n];
for(int i = 0; i < n ; i++){
cin >> arr[i];
}
long long int ans  =  -999999;
long long int sum = 0;
for(int i = 0;i < n ;i++){
sum+=arr[i];
ans = max(ans,sum);
if(sum<0){sum = 0;}
}
cout << ans << endl;
}

Solution in python :

n = int(input())
a = list(map(int, input().split(" ")))
max_so_far = -1e18 - 1
max_ending_here = 0

for i in range(n):
max_ending_here = max_ending_here + a[i]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here

if max_ending_here < 0:
max_ending_here = 0
print(max_so_far)
2 Likes