❓ Question https://www.hackerrank.com/challenges/weather-observation-station-15 Weather Observation Station 15 | HackerRank Query the Western Longitude for the largest Northern Latitude under 137.2345, rounded to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(long_w,4) FROM station WHERE lat_n = (SELECT MAX(lat_n) FROM station WHERE lat_n < 137.2345); 📌 Discussion sub query scalar로 W..
❓ Question https://www.hackerrank.com/challenges/weather-observation-station-14 Weather Observation Station 14 | HackerRank Query the greatest value of the Northern Latitudes from STATION that are under 137.2345 and truncated to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(MAX(lat_n),4) FROM station WHERE lat_n < 137.2345; 📌 Discussion WHERE 절에서 조건을 주고 MAX값을 추출 후 ROUND로 반올림
❓ Question https://www.hackerrank.com/challenges/weather-observation-station-13 Weather Observation Station 13 | HackerRank Query the sum of Northern Latitudes having values greater than 38.7880 and less than 137.2345, truncated to 4 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(SUM(lat_n),4) FROM station WHERE lat_n BETWEEN 38.7880 AND 137.2345; 📌 Discussion WHERE 절에서 BETWEEN으로 범위 조건..
❓ Question https://www.hackerrank.com/challenges/weather-observation-station-2 Weather Observation Station 2 | HackerRank Write a query to print the sum of LAT_N and the sum of LONG_W separated by space, rounded to 2 decimal places. www.hackerrank.com ❗ Answer SELECT ROUND(SUM(lat_n),2), ROUND(SUM(long_w),2) FROM station; 📌 Discussion 모든 lat_n과 long_w를 각각 합친 후 ROUND로 반올림하여 소수점 둘째자리까지 표현한다.
❓ Question https://www.hackerrank.com/challenges/earnings-of-employees Top Earners | HackerRank Find the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount). www.hackerrank.com ❗ Answer SELECT months*salary, COUNT(*) FROM employee WHERE months*salary = (SELECT max(months*salary) FROM employee) GROUP BY months*salary; 📌 Discuss..
❓ Question https://www.hackerrank.com/challenges/revising-aggregations-the-count-function Revising Aggregations - The Count Function | HackerRank Query the number of cities having populations larger than 100000. www.hackerrank.com ❗ Answer SELECT COUNT(name) FROM city WHERE population > 100000; 📌 Discussion where에서 조건문을 걸어주고 count로 집계
📌문제 출처 백준 단계별 문제풀이 - 동적 계획법 2 https://www.acmicpc.net/problem/11066 11066번: 파일 합치기 소설가인 김대전은 소설을 여러 장(chapter)으로 나누어 쓰는데, 각 장은 각각 다른 파일에 저장하곤 한다. 소설의 모든 장을 쓰고 나서는 각 장이 쓰여진 파일을 합쳐서 최종적으로 소설의 완성본 www.acmicpc.net ❓ 문제 ❗ 풀이 누적합, 동적계획법 📗 풀이 코드 --- python 3는 시간 초과 / pypy3는 통과 import sys input = sys.stdin.readline # 누적합 구하는 함수 def prefix(chaps): sum_prefix = [0] tmp_sum = 0 for chap in chaps: tmp_sum +..
❓ Question https://www.hackerrank.com/challenges/the-blunder The Blunder | HackerRank Query the amount of error in Sam's result, rounded up to the next integer. www.hackerrank.com ❗ Answer SELECT ROUND(AVG(salary))-ROUND(AVG(replace(salary,'0',''))) FROM employees; 📌 Discussion replace로 salary column의 string data의 '0'을 ''으로 변경 AVG는 숫자로 구성된 문자열도 집계 가능 개별 평균값을 반올림한 값의 차이를 계산해줌