[OA] Twilio | L2 (Full Stack) | Remote/Bangalore | Sept 2022 [Passed]
Anonymous User
492

YOE: 4 years, 2 months
Current Company: Small sized startup

I have been approached by HR on Linkedin. After showing interest, I received hackerrank test link for OA.

Format:
3 Questions to be solved in 115 minutes. 1 Coding + 1 REST API based Question + 1 React Based Front end Question

Q1: Problem Solving
Difficulty level: Easy
You have given records in 2D array format, where each record represents borrower, lender and amount (given to borrower by lender). return the number of people who has maximum debt (negative balance termed as debt. For e.g. -10 is max debt than -1) in albhapetical order. If no people has maximum debt return empty array.

Input:

[
	["Alex", "Bob", "5"],
	["Alex", "Ceasy", "12"],
	["Ceasy", "Bob", "9"],
	["David", "Alex" "8",]
	
]

Output:

["Alex", "Ceasy"]

Solution:
Initiaize empty dict/hashmap balanceRecords.
Loop over 2d array and for each record, dedcut amount from borrower and add amount to lender

balanceRecords[borrower] = balanceRecords[borrower] - amount
balanceRecords[lender] = balanceRecords[lender] + amount

Finally loop over dict/hashmap and find out max debt people and store them in results.
Note: Keep max_debt as 0 as you have to find out negative balance
Sort the results and return array

Result: Passed all test cases

Q2: REST API
Difficulty level: Easy
Given country as string paramter, make a call to REST API with query params as ?country=<country> return capitalCity from response data if country is present else return "-1".
The data was paginated so we have to keep searching pages till we read all pages and if not found return "-1"

Q3: React based Question
Difficulty level: Easy~Medium based on react expertise
You have given pre designed kanban board page listing n number of tasks in different stages ["TODO", "IN_PROGRESS", "COMPLETED", "RELEASED"]
Each task is a card with heading as task name and two buttons at the bottom right corner of the task. One is forward arrow to move task from current stage to next stage and backward arrow to move task from current stage to previous stage.
Your task is to move task as per the button (forward or backward) on clicking on the button and make the foward button disabled in the last stage and backward button disabled in first stage.
Task is list of objects stored in the state of class based components with name as unqiue identifier and stage as integer showing current stage 0 for "TODO" and like that 3 for "RELEASED"

Solution
Write onclick handler for button updateStage(task, updatedStage)
Call this handler on foward button as updateStage(task, task.stage+1) and for backward updateStage(task, task.stage-1)
Update stage of the task if updatedStage is greater than -1 and less than 4.
For Forward button add attribute disabled if the task in last stage and opposite for backward button

Result: Passed all test cases

Comments (1)