# Agoda Bangkok Thailand Interview Java

## Agoda Bangkok Thailand Interview Java

race condition
SOLID design principal
Memory Increasing with time with CPU constant, how to fix on production environment ?
Cap Theorem
Composition vs association
Should misrocservices be async ?

## Design Distributed Scheduler ?

Given following SQL table with 500 million entries

user_id, job_id(primary key), frequency, http_url, is_enabled

http_url: is http url that returns 200 OK response on GET request

user_id: Is user identifier, one user can have multiple records in the table

output should be as follows :

job_id : latency, status code, paylpoad size

Solution : Distribute load based on range of job-id (range based partition) along with caching along with writing back the result as a master-slave replica.

## Given that we are getting a stream of parent child relationship, where first element is parent and secind is child. We need to find the entries with 0 and 2 parents.

1 3
\ / \
2 5
/ / \
4 6 7
\ /
8

(1,2)
(3,2)
(3,5)
(2,4)
(5,6)
(5,7)
(4,8)

Entries with 0 parent – 1,3
Entries with 2 parents – 2,8

class Solution {
public static void insert(int x , int y,HashMap> hm)
{
if(hm.containsKey(y))
{
List temp = hm.get(y);
temp.add(x);
hm.put(y,temp);
}
else
{
List p= new ArrayList<>();
p.add(y);
hm.put(y,p);
}

if(!hm.containsKey(x)){ List p= new ArrayList<>(); hm.put(x,p); } }

public static void main(String[] args) {

HashMap> hm = new HashMap<>();

// Enter entries in hm
// for every element
insert(1,2,hm);
insert(3,2,hm);
insert(3,5,hm);
insert(5,6,hm);
insert(5,7,hm);
insert(4,8,hm);

// (1,2)
// (3,2)
// (3,5)
// (2,4)
// (5,6)
// (5,7)
// (4,8)

System.out.println(“2 parents :”);

for(Integer i : hm.keySet()) {

if(hm.get(i).size() ==2)

System.out.println(i);

}

System.out.println(“0 parents :”);

for(Integer i : hm.keySet()) {

if(hm.get(i).size() ==0)

System.out.println(i);

// add to list with 2 parents

//if(hm.get(i).size() ==0)

// add to list with 0 parents }

}
}

## Design Question

Design a highly scalable distributed Scheduler that would hit each job id with mentioned frequency

Given following SQL table with 500 million entries
user_id, job_id, frequency, http_url, is_enabled
user_id: Is user identifier, one user can have multiple records in the table
http_url: is http url that returns 200 OK response on GET request
Create a table with entry for job_id and following details
latency, status code, paylpoad size
Solution on the line of following link:

https://medium.com/walmartlabs/an-approach-to-designing-distributed-fault-tolerant-horizontally-scalable-event-scheduler-278c9c380637

# Resolving technical problems:

Solve your technical problems instantly

We provide Remote Technical Support from Monday to Sunday, 7:00PM to 1:00 AM

Mail your problem details at [email protected] along with your mobile numberand we will give you a call for further details. We usually attend your problems within 60 minutes and solve it in maximum 2 days.

## One thought on “Agoda Bangkok Thailand Interview Java”

Comments are closed.