Open In App

PayPal Interview Experience for SDE-2

Last Updated : 28 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

I reached out to the Hiring Manager via LinkedIn. The very next day HR reached out to me with the interview details. Had a brief conversation with her about my profile, and experience, with the role. I asked for some time to prepare for the rounds, so the rounds were scheduled after two weeks. In the meantime, they scheduled a meeting with the hiring manager to discuss the job insights and the role. He gave a brief and introduced himself as well as answered all my questions as it was a 1:1 session. Next the interview rounds.

Round1 (Coding Round) :

First Question:

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.
Merge nums1 and nums2 into a single array sorted in non-decreasing order.
The final sorted array should not be returned by the function, but instead be stored inside the array nums1.To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.
Example 1:
Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
Output: [1,2,2,3,5,6]
Explanation: The arrays we are merging are [1,2,3] and [2,5,6].
The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1.

Example 2:
Input: nums1 = [1], m = 1, nums2 = [], n = 0
Output: [1]
Explanation: The arrays we are merging are [1] and [].
The result of the merge is [1].
Note that because m = 0, there are no elements in nums1. The 0 is only there to ensure the merge result can fit in nums1.
This was the first question.

Second Question:

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise.
Example 1:
Input: arr = [1,2,2,1,1,3]
Output: true
Explanation: The value 1 has 3 occurrences, 2 has 2, and 3 has 1. No two values have the same number of occurrences.
Example 2:
Input: arr = [1,2]
Output: false
Example 3:
Input: arr = [-3,0,1,-3,1,1,1,-3,10,0]
Output: true

Constraints:
1 <= arr.length <= 1000
-1000 <= arr[i] <= 1000

Round 2 (Hiring Manager round):

Started with a self-introduction and then he asked questions on projects, some questions on testing, java, and as well as SQL.

Next, he jumped to the coding question :

Calculating the number of ways you can reach a value with coins is a classic computer science problem.
Specifically, given a list of integers coins and an integer target, how many combinations of coin members are there that sum to the target if you can use each member of coins unlimited times?
For example:
coins = [2, 5, 6]
target = 10
output: 3
Explanation: There are three ways to get 10 with the given coins.
2 + 2 + 2 + 2 + 2
5 + 5
6 + 2 + 2
This problem is often solved with dynamic programming using a list for memoization. Each index of the list represents the number of ways to get the index's integer value with coins.
For the above example, the list would be: [1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 3]
The 0th index is 1 because there is 1 way to get no coins.
The last index is the solution because it has the index target.
The 6th index is 2 because the 2 ways to get a value of 6: Use 1 coin with a value of 6 or use 3 coins with value 2.

Here is an example solution:

def coin_change(coins, target):
dp = [1] + [0] * target
for coin in coins:
for i in range(coin, len(dp)):
dp[i] += dp[i-coin]
return dp[-1]
print(coin_exchange([1], 5)) # Outputs 1.
print(coin_change([2, 5, 6], 10)) # Outputs 3.
print(coin_exchange([1, 2, 3, 4], 4)) # Outputs 5.

Second Questions

Solve the reverse of the Coin Change Problem. Given a memoized list of how many ways there are to reach a coin value, return the original list of coins. If there is no list of coins that can yield the input memoization, return None.
For example:
dp = [1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 3]
output: [2, 5, 6]
dp = [1, 1, 1, 3, 2]
output: None
dp = [1,1]
output:[1]
[1,1,1] target=2

Had only two rounds. The second one was quite tough. Optimization is mandatory. This round depends on the manager and could be a technical discussion or even a design discussion. Had two rounds on two consecutive days and the results were declared in two hours.

Suggestion: Discuss the question with the interviewer. Think out loud, tell them your approach, and always have a conversation about the cases, ask about the edge cases, and also try to optimize your solution. I didn’t solve too many questions. But I definitely did solve quality questions. Also, try to keep your code clean(saying this from my experience). Have another interview lined up as well, would try to share the questions.

Verdict: SELECTED


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads