I would like to design an API / That solves the following Problem.
Given a two-dimensional matrix, each of the entries represents a person:
1 0 1
0 0 0
0 1 0
If the entry is 1, we consider the represented person to be sick and we recognize this person as a patient. If two patients are adjacent to each
other in any direction (vertical, horizontal and oblique), we consider them part of the same patient group. For example, the following matrix
contains 4 patient groups:
1 1 0 0 0 0
0 1 0 0 0 0
1 0 1 0 0 0
0 0 0 0 1 0
0 0 0 0 0 1
1 1 0 1 0 0
Your API will receive a request like the following:
POST /api/patient-groups/calculate HTTP/1.1
Host: {url}:{port}
Content-Length: {content_length}
content-type: application/json
Accept: *
{
"matrix" : [
[1, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
[1, 1, 0, 1, 0, 0]
]
}
And return a response body like this:
{
"numberOfGroups": 4
}
Here is another example:
{
"matrix" : [
[1, 0, 1, 1, 1],
[1, 0, 0, 0, 0],
[1, 0, 0, 0, 1],
[0, 0, 1, 0, 0],
[0, 1, 0, 0, 0],
[0, 1, 0, 0, 1]
]
}
And the response body should be:
{
"numberOfGroups": 5
}
What I have tried:
I am trying to develop this thing Using .NET Core services libraries. need to HOST using HTTP protocol, and Creating client for sending request. with 1.) Code Maintainability 2) Memory Usage 3) Time Complexity 4) Testability.
Any One Suggest Which approach is better with which programming language and on which environment.
Thanks in Advance.
With Regards.
Neel.