Stripe OA 2026 | SSE3
Anonymous User
649

Store all datacentres and their details. Calculate the routing distance
Part 1:
Input:-
REGISTER <region> <latitude> <longitude> <capacity>
SET_HEALTHZ <region> <state>
Sample Input:-

REGISTER us-east-1 38 120 100
REGISTER us-west-2 50 112 30
SET_HEALTHZ us-west-2 false
REGISTER eu-east-1 -10 15 0

Output:-

OK (if register is successful)
ERROR (if it fails the rules)

Rules:

  • Latitude should be between [-90,90]
  • Longitude should be between [-180,180]
  • capacity should be > 0
  • Region should not already been registered for REGISTER call but should be registered for SET_HEALTHZ call
  • Assume latitude and longitude are integers and so is capacity. healthz will always be boolean
  • By default new regions are always healthy

Part 2:
Calculate the Haversine distance between two sets of coordinates. (Haversine algorithm is given for implementation)
Input:-
DISTANCE <lat1> <long1> <lat2> <long2>
Sample input:-
DISTANCE 0 0 100 100
Output:-
10200

Constraints:-
Input will be integer and output needs to be rounded to integer

Part 3:-
Calculate proximity routing for the given coordinates to a region registered and return the only healthy region and which can handle the load and possible candidates for the routing. Also add the distance of the region from the request. (Based on haversine in part 2)
Input:-
ROUTE <latitude> <longitude>
Sample Input:-

REGISTER us-east-1 0 0 1
REGISTER ap-south-1 0 0 1
ROUTE 0 0
SET_HEALTHZ ap-south-1 false
ROUTE 0 0

Output:-

OK
OK
us-east-1 0 us-east-1 ap-south-1
NONE 0 us-east-1

Rules:

  • If a region is unhealthy dont include it in candidates as well as it cannot be a node on which it is routed.
  • Load initially of all registered regions is 0
  • If no region can be routed for the request, output NONE and the haversine distance will be 0 in that case
  • Latitude and longitude constraints are same as part 1
  • Region needs to be choosen based on distance and if distance is same, then alphabetical order

Time limt is 1Hr and need to process input and output from scratch. Platform is hackerrank.

Comments (0)