PhonePe Online Assessment Questions

Position : Software Development Engineer
Location : Bangalore

Attended Online Assessment on Codesignal

Question 1 :
Given a square matrix of integers m , your task is to rearrange its numbers in the following way:

  • First,sort its values in ascending order of how frequently the number occurs in m in case of a tie, sort the equally frequent numbers by their values, in ascending order.

  • Second, place the sorted numbers diagonally, starting from the bottom right corner.

Example :

input
m = [[1,4,-2],[-2,3,4],[3,1,3]]

output
[[3,3,4],[3,4,1],[1,-2,-2]]

Question 2 :
You have been asked to program a bot for a popular bank that will automate the management of incoming requests. There are three type of requests the bank can receive.

  1. transer i j sum : request to transfer sum amount of money from the ith account to the jth one (i and j are 1-based index).

  2. deposit i sum : request to deposit sum amount of money in the ith account (1-based index).

  3. withdraw i sum : request to withdraw sum amount of money from the ith account (1-based index).

You should also be able to process invalid requests. There are two types of invalid requests.

  • invalid account number in the requests.
  • withdrawal /transfer of a larger amount of money than is currently available.

Example 1 :

input
balance  =  [10,100,20,50,30]
request = ["withdraw 2 10", "transfer 5 1 20",  "deposit 5 20",  "transfer 3 4 15"]

output 
[30,90,5,65,30]

Example 2 :

Input
balance = [20,1000,500,40,90]
requests = ["deposit 3 400", "transfer 1 2 30", "withdraw 4 50"]

output
[-2]

Question 3 :
You are given an array of distinct non-negative integers arr and an array of integer arrays pieces. Your task is to check whether it is possible to arrange the arrays of pieces in such a way that they can be concantenated to form an array equal to arr ( containing all the same elements in the same order).

Example 1 :

input
arr = [1,2,5,3]
pieces = [[5],[1,2],[3]]

output
true

Example 2 :

input
arr = [1,5,4,3,2,8]
pieces = [[4,3],[1,5],[2]]

output
false

Note - Execution Time Limit is 0.5 Seconds

Comments (16)