PhonePe interview experience Real time questions & tips from candidates to crack your interview

Software Engineer

PhonePe
upvote
share-icon
3 rounds | 7 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 6 months
Topics: Data Structure, Algorithm, OOPS, DP, Puzzles
Tip
Tip

Tip 1: Don't waste much time on easy questions
Tip 2: If you can't make a solution to the problem. Check out other's solution
Tip 3: Do some good projects

Application process
Where: Campus
Eligibility: 6 CPI and above
Resume Tip
Resume tip

Tip 1: Write only those skills in which you are confident
Tip 2: Have a variety of achievements in your resume

Interview rounds

01
Round
Medium
Online Coding Test
Duration120 mins
Interview date5 Aug 2022
Coding problem3

This was an online coding round with 4 coding questions.

1. Search In A Row Wise And Column Wise Sorted Matrix

Moderate
15m average time
80% success
0/80
Asked in companies
AdobeNoBrokerOracle

You are given an 'N * N' matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'.


Find the position of 'X' in the matrix. If it exists then return the pair {i, j} where 'i' represents the row and 'j' represents the column of the array, otherwise return {-1,-1}


For example:
If the given matrix is:
[ [1, 2, 5],
  [3, 4, 9],
  [6, 7, 10]] 
We have to find the position of 4. We will return {1,1} since A[1][1] = 4.
Problem approach

This was the standard problem. I directly solved this through binary search with a little bit of modification.

Try solving now

2. Gas Stations

Moderate
10m average time
90% success
0/80
Asked in companies
AtlassianGoldman SachsAmazon

You have been given a circular path. There are 'N' petrol pumps on this path that are numbered from 0 to N - 1 (Both inclusive). Each petrol pump has two values associated with it:

1)The amount of petrol that is available at this particular petrol pump.
2)The distance to reach the next petrol pump.

You are on a truck having an empty tank of infinite capacity. You can start the tour from any of the petrol pumps. Your task is to calculate the first petrol pump from where the truck will be able to complete the full circle or determine if it is impossible to do so.

You may assume that the truck will stop at every petrol pump and it will add the petrol from that pump to its tank. The truck will move one kilometre for each litre of petrol consumed.

Problem approach

I first wrote some random test cases and tried to find solutions manually.
Then I observed one hint in the solutions if we can't reach any point, then any point before that point can't be the answer.
Finally, after a lot of trials, I solved this in linear time.

Try solving now

3. Palindromic Substrings

Moderate
20m average time
80% success
0/80
Asked in companies
MicrosoftSalesforceAmazon

You have been given a string STR. Your task is to find the total number of palindromic substrings of STR.

Example :
If the input string is "abbc", then all the possible palindromic substrings would be: ["a", "b", "b", c", "bb"] and hence, the output will be 5 since we have 5 substrings in total which form a palindrome.
Note :
A string is said to be a 'Palindrome' if it is read the same forwards and backwards. 
For example, “abba” is a palindrome, but “abbc” is not.

A 'Substring' is a contiguous sequence of characters within a string. 
For example, "a", "b", "c", "ab", "bc", "abc" are substrings of "abc".
Problem approach

I was not able to write the tabular DP solution at that instant, so I wrote recursive solution with memorization.

Try solving now
02
Round
Medium
Face to Face
Duration60 mins
Interview date6 Aug 2022
Coding problem2

Interviews were conducted in offline mode.

1. Smallest Subarray With K Distinct Elements

Easy
20m average time
80% success
0/40
Asked in companies
IntuitUberGoldman Sachs

Given an array 'A' consisting of 'N' integers, find the smallest subarray of 'A' containing exactly 'K' distinct integers.

Note :
If more than one such contiguous subarrays exist, consider the subarray having the smallest leftmost index.

For example - if A is [1, 2, 2, 3, 1, 3 ] and k = 2 then the subarrays: [1,2], [2,3], [3,1], [1,3] are the smallest subarrays containing 2 distinct elements. In this case, we will consider the starting and ending index of subarray [1,2] i.e. 0 and 1.
Problem approach

In the first step, I told the brute force approach.
Then I solved this problem using sliding window.

Try solving now

2. Next Greater Element

Moderate
20m average time
90% success
0/80
Asked in companies
CIS - Cyber InfrastructureAmazonPhonePe

You are given an array arr of length N. You have to return a list of integers containing the NGE(next greater element) of each element of the given array. The NGE for an element X is the first greater element on the right side of X in the array. Elements for which no greater element exists, consider the NGE as -1.

For Example :

If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
Problem approach

I just reversed the array and wrote the code for next greater element. Then reversed the resultant array.

Try solving now
03
Round
Hard
Face to Face
Duration80 mins
Interview date6 Aug 2022
Coding problem2

All the questions were based on graph.

1. Dijkstra's shortest path

Moderate
25m average time
65% success
0/80
Asked in companies
PayPalAmazonPhonePe

You have been given an undirected graph of ‘V’ vertices (labeled 0,1,..., V-1) and ‘E’ edges. Each edge connecting two nodes (‘X’,’Y’) will have a weight denoting the distance between node ‘X’ and node ‘Y’.

Your task is to find the shortest path distance from the source node, which is the node labeled as 0, to all vertices given in the graph.

Example:

Input:
4 5
0 1 5
0 2 8
1 2 9
1 3 2
2 3 6

alt text

In the given input, the number of vertices is 4, and the number of edges is 5.

In the input, following the number of vertices and edges, three numbers are given. The first number denotes node ‘X’, the second number denotes node ‘Y’ and the third number denotes the distance between node ‘X’ and ‘Y’.

As per the input, there is an edge between node 0 and node 1 and the distance between them is 5.

The vertices 0 and 2 have an edge between them and the distance between them is 8.
The vertices 1 and 2 have an edge between them and the distance between them is 9.
The vertices 1 and 3 have an edge between them and the distance between them is 2.
The vertices 2 and 3 have an edge between them and the distance between them is 6.

Note:

1. There are no self-loops(an edge connecting the vertex to itself) in the given graph.

2. There can be parallel edges i.e. two vertices can be directly connected by more than 1 edge.
Problem approach

Found all shortest path using Dijkstra Algorithm with little modification.
Took the union of edges of all the paths.

Try solving now

2. Accounts Merge

Hard
15m average time
85% success
0/120
Asked in companies
PhonePeAmazonFacebook

You have been given an array/list 'accounts' where each element, i.e. 'accounts'[i] contains a list of strings.


In 'accounts'[i], the first element is the name of the account holder, and the rest of the strings are emails representing the emails of the account.


Now, you are supposed to merge the accounts. Two accounts definitely belong to the same person if there is some email that is common to both accounts. Note that it may be possible that two accounts belong to the same name, but they may belong to different people, as people could have the same name.


A person could have any number of accounts initially, but all their accounts definitely have the same name.


After merging the accounts, you have to return an array/list of merged accounts where each account, the first element is the person's name, and the rest elements are the email addresses in sorted order (non-decreasing). Accounts themselves can be in any order.


Example:
 Input:  'n' = 4,
 'accounts' = [
    ["Rohan", "rohan123@gmail.com", "1279ro@gmail.com"],
    ["Rohit", "rohit101@yahoo.com", "hitman30487@gmail.com"],
    ["Rohan", "1279ro@gmail.com",  "niemann01@gmail.com"],
    ["Rohan", "kaushik@outlook.com"],
 ]
 Output: [
    ["Rohan", "rohan123@gmail.com", "1279ro@gmail.com", "niemann01@gmail.com"],
    ["Rohit", "rohit101@yahoo.com", "hitman30487@gmail.com"],
    ["Rohan", "kaushik@outlook.com"],
 ]

 Explanation: The first and third "Rohan" are the same person as they have a shared email address, “1279ro@gmail.com”. The rest of the accounts are of different persons, as they don’t share any shared email addresses. So, we merge the first and third accounts.
Problem approach

First I gave the map-based approach but that approach failed in some test cases.
Finally, I gave DSU based solution.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
company logo
Software Development
3 rounds | 5 problems
Interviewed by PhonePe
12565 views
0 comments
0 upvotes
company logo
Software Engineer
3 rounds | 6 problems
Interviewed by PhonePe
3842 views
0 comments
0 upvotes
company logo
Software Engineer
3 rounds | 4 problems
Interviewed by PhonePe
4917 views
0 comments
0 upvotes
company logo
Software Engineer
3 rounds | 5 problems
Interviewed by PhonePe
4965 views
1 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Engineer
3 rounds | 7 problems
Interviewed by Optum
7874 views
1 comments
0 upvotes
company logo
Software Engineer
5 rounds | 5 problems
Interviewed by Microsoft
9973 views
1 comments
0 upvotes
company logo
Software Engineer
2 rounds | 4 problems
Interviewed by Amazon
4310 views
1 comments
0 upvotes