PayPal SWE Summer Internship 2024
Totally 5 mcq questions and 1 coding question was asked in the Round 1.
Technical mcq questions where from DSA and OOPS.
Test Duration: 40 mins.
This round was conducted at Hackerrank.
Coding question:
Break Sort
Given an array arr of n positive integers, the following operations can be performed 0 or more times:
Choose an index i where 0 <= i < n
choose 2 integers, x and y, such that x + y = arr[i]
replace arr[i] with two elements, the two values x and y
Determine the minimum number of operations required to sort the array.
Example
n = 3
arr = [3, 4, 3]
The array can be sorted in 2 operations:
Choose i = 0 arr[0] = 3. Choose x = 1 and y = 2. Replace am[0] with x and y arr = [1, 2, 4, 3].
Choose i = 2 arr[2] = 4. Choose x = 2 and y =2. Replace am[2] and arr = [1, 2, 2, 2, 3].
Return 2.
Code:
long long minOperations(vector<int>& v) {
long long ans = 0;
long long Maxmin = v[v.size()-1];
for(int i = v.size() - 2; i >= 0; i--){
if(v[i] > Maxmin){
int partition = ceil(v[i] / double(Maxmin));
ans += partition - 1;
Maxmin = v[i]/partition;
}
else
Maxmin = v[i];
}
return ans;
}
This OA took place on 30-10-2023
I heard back from PayPal University Hiring after 15 days and I was selected for the interview process.