Sort 1202 Discussions, By:
Please Login in order to post a comment
Somehow this assignment does not make sense to me. Why should P1 be a point on the 2d-Plane when both components lie in the same dimension? Same for P2. P1 = (a,c) and P2 = (b,d) would make much more sense.
oracle / mysql -
select round(abs(min(lat_n)-max(lat_n))+abs(min(long_w)-max(long_w)),4) from station;
My MS SQL solution:
SELECT CAST((ABS(MAX(LAT_N)-MIN(LAT_N)) + ABS(MAX(LONG_W)-MIN(LONG_W))) AS NUMERIC(18,4)) FROM STATION;
Here is Oracle solution from my HackerrankPractice repository:
SELECT ROUND(MAX(Lat_N) - MIN(Lat_N) + MAX(Long_W) - MIN(Long_W), 4)
Feel free to ask if you have any questions :)
Shouldn't the manhattan distance between two points on a plane be |deltaX| + |deltaY| or |lat| + |long| -> which would make the solution |maxLat - minLat| + |maxLong - minLong|? It doesn't make sense to me why we subtract lat from long in the given solution. Is that just the arbitrary way that the problem is defined?