일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- select
- SQL
- 개발자의 책장
- MySQL
- 프로그래머스
- Hackerrank
- array.slice()
- node.js
- 배열
- 코플릿
- 코딩테스트
- JavaScript
- array
- 역행자
- Developer_JoyKim
- 블록체인
- 정규표현식
- for문
- 자바스크립트
- 코딩공부
- join
- 개발자_조이킴
- Algorithms
- Where
- 재귀함수
- 코드스테이츠
- 최강의 인생
- Programmers
- 알고리즘
- array.push()
- Today
- Total
CodingSpace
[HackerRank/SQL] Aggregation - Weather Observation Station 18 본문
[HackerRank/SQL] Aggregation - Weather Observation Station 18
개발자_조이킴 2022. 8. 2. 09:17Problem. Basic Select - Weather Observation Station 18
Link.
https://www.hackerrank.com/challenges/weather-observation-station-18/problem?isFullScreen=true
Weather Observation Station 18 | HackerRank
Query the Manhattan Distance between two points, round or truncate to 4 decimal digits.
www.hackerrank.com
Description.
Consider P1(a, b) and P2(c, d) to be two points on a 2D plane.
- a happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
- b happens to equal the minimum value in Western Longitude (LONG_W in STATION).
- c happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
- d happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points and and round it to a scale of 4 decimal places.
Key Point.
Manhattan Distance
A(x1, y1)와 B(x2, y2)의 멘하탄 거리는
Manhattan Distance = |x1 - x2| + |y1 - y2|
ROUND,
ABS,
MIN,
MAX,
My Answer.
SELECT
ROUND(ABS(SS.a - SS.c) + ABS(SS.b - SS.d), 4)
FROM
(SELECT
MIN(LAT_N) AS a,
MIN(LONG_W) AS b,
MAX(LAT_N) AS c,
MAX(LONG_W) AS d
FROM STATION
) AS SS;
References.
Manhattan Distance: https://xlinux.nist.gov/dads/HTML/manhattanDistance.html
Manhattan distance
Definition: The distance between two points measured along axes at right angles. In a plane with p1 at (x1, y1) and p2 at (x2, y2), it is |x1 - x2| + |y1 - y2|. Note: This is easily generalized to higher dimensions. Manhattan distance is often used in inte
xlinux.nist.gov
'HackerRank > SQL' 카테고리의 다른 글
[HackerRank/SQL] Aggregation - Weather Observation Station 20 (0) | 2022.08.04 |
---|---|
[HackerRank/SQL] Aggregation - Weather Observation Station 17 (0) | 2022.08.02 |
[HackerRank/SQL] Aggregation - Weather Observation Station 15 (0) | 2022.08.01 |
[HackerRank/SQL] Aggregation - Weather Observation Station 14 (0) | 2022.08.01 |
[HackerRank/SQL] Aggregation - Weather Observation Station 13 (0) | 2022.07.31 |