Skip to content
Related Articles

Related Articles

Improve Article

PhonePe Online Assessment Interview Experience

  • Last Updated : 02 Sep, 2021
Geek Week

First round was a coding round in which 4 questions were asked.

Q1. Given an array A[] of N elements, You’d like to know how many triangles can be formed with side lengths equal to adjacent elements from A[].

Construct an array of integers of length N – 2 where ith element is equal to 1 if it is possible to form a triangle with side lengths A[i], A[i+1], and A[i+2]. otherwise 0.

Note: A triangle can be formed with side lengths a, b and c if a+b>c and a+c>b and b+c>a.

Example 1:



Input:

N = 4

A[] = {1, 2, 2, 4}

Output:

1 0

Explanation:

output[0] = 1 because we can form a

triangle with side lengths 1,2 and 2.

output[1] = 0 because 2+2<4 so, we cannot

form a triangle with side lengths 2,2 and 4.

Q2. Given an array numbers[] of N positive integers and a positive integer X, The task is to find the number of ways that X can be obtained by writing pair of integers in the array numbers[] next to each other. In other words, find the number of pairs (i,j) such that i != j and X is the concatenation of numbers[i] and numbers[j]

Example 1:

Input:

N = 4  

numbers[] = {1, 212, 12, 12}

X = 1212

Output:

3



Explanation:

We can obtain X=1212 by concatenating:

numbers[0] = 1 with numbers[1] = 212

numbers[2] = 12 with numbers[3] = 12

numbers[3] = 12 with numbers[2] = 12

 
 

Hey geek! It’s time to become a success story instead of reading them. Check out our most renowned DSA Self Paced Course, now at a student-friendly price and become industry ready. And if you are looking for a more complete interview preparation resource, check out Complete Interview Preparation Course that will prepare you for the SDE role of your dreams!

Feeling prepared enough for your interview? Test your skills with our Test Series that will help you prepare for top companies like Amazon, Microsoft, TCS, Wipro, Google and many more!

My Personal Notes arrow_drop_up
Recommended Articles
Page :