해커랭크SQL문제_0719
Weather Observation Station5 문제: Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. 풀이: CITY를 우선 알파벳 순으로 정렬을 하고 글자수를 카운트해서 제일 글자수가 적은 것, 제일 글자수가 큰 것을 출력하는 문제. 해결하는데 20 ~ 30분정도나 꽤 길게 걸렸..
2021.07.19
해커랭크 SQL문제_0717
Weather Observation Station4 문제: Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. Where LAT_N is the northern latitude and LONG_W is the western longitude. For example, if there are three records in the table with CITY values 'New York', 'New York', 'Bengalaru', there are 2 different city names: 'New York' and 'Bengal..
2021.07.17
2021.07.16
백준 3단계(1번 ~ 2번 문제) 1번 문제는 몇 단인지 정수 하나 입력 받아서 구구단 출력하는 문제. 2번 문제는 두 정수를 입력받아서 합을 구하는데, 테스트 케이스의 갯수를 입력받아서 그 갯수만큼 반복하도록 구현해야 하는 문제. Scanner input = new Scanner(System.in); int t_num, su1, su2; t_num = input.nextInt(); for(int i = 0; i < t_num; i++) { su1 = input.nextInt(); su2 = input.nextInt(); System.out.println(su1 + su2); } 프로그래머스 코딩테스트 연습 - 짝수와 홀수 정수 num이 짝수일 경우 "Even"을 반환하고 홀수인 경우 "Odd"를 반환하..
2021.07.16
해커랭크 SQL문제_0716
Weather Observation Station2 문제: Query the following two values from the STATION table: The sum of all values in LAT_N rounded to a scale of decimal places. The sum of all values in LONG_W rounded to a scale of decimal places. Output Format Your results must be in the form: lat lon where is the sum of all values in LAT_N and is the sum of all values in LONG_W. Both results must be rounded to a s..
2021.07.16
2021.07.15
백준 2단계(1번 ~ 5번 문제) 1번 문제의 경우 두 수 입력받아서 if ~ else if ~ else문으로 비교하여 특정 문자 출력하기. 2번 문제의 경우 "시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램을 작성" 하는 문제이다. 1 번 문제와 동일하게 if ~ else if ~ else로 구현 가능하다. switch문으로도 바꿔보기. Scanner input = new Scanner(System.in); int score; score = input.nextInt(); if(score >= 90 && score = 80 && score < 90) { System.out.println('B'); }..
2021.07.15
해커랭크 SQL문제_0715
Japanese Cities' Name 문제: Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN. The CITY table is described as follows: 풀이: WHERE절에 COUNTRYCODE 조건을 주고 SELECT시 name만 출력되게. Weather Observation Station 1 문제: Query a list of CITY and STATE from the STATION table. The STATION table is described as follows: 풀이: STATION 테이블에서 CITY랑 STATE 컬럼만 출력. SELECT CITY, ST..
2021.07.15
해커랭크 SQL 문제_0714
Select By ID 문제: Query all columns for a city in CITY with the ID 1661. The CITY table is described as follows: 어제 문제와 동일한 테이블을 사용. 풀이: ID가 1661인 컬럼 찾아서 모든 속성들 출력해주기. SELECT 시 컬럼 하나하나 출력해도 되지만, 모든 컬럼 출력 시 SELECT문에 * 사용으로 간단히 쿼리를 만들어 줄 수도 있다! Japanese Cities' Attributes 문제: Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN. The CITY table is described..
2021.07.14
2021.07.13
백준 1단계 입출력과 사칙연산(6 ~ 11번 문제) 6번과 7번 문제의 경우 5번 문제인 두 수의 합 구하는 것에서 연산자만 -로, *로 바꿔주면 해결. 8번 문제의 경우 두 수를 입력받아 나눗셈 연산. 나눗셈의 결과가 딱 정수로 나누어 떨어질 수도 있지만 1 / 3의 경우 0.333333333..으로 나올 수도 있음. 따라서 double형 변수로 선언해주고 nextDouble()로 입력받기. 9번 문제의 경우 두 수를 입력받아 사칙연산 및 나머지 출력하는 문제. 10번 문제의 경우 % 연산자와 관련된 문제. (A+B)%C는 ((A%C) + (B%C))%C 와 같을까? (A×B)%C는 ((A%C) × (B%C))%C 와 같을까? 직접 코드로 확인한 결과 같은데 문자로 생각이 어렵다면 숫자를 임의로 집어넣..
2021.07.13
해커랭크 SQL문제_0713
Revising the Select Query II 문제: Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA. 풀이: 문제를 해석해보면 population이 120,000이상인 countrycode가 USA인 컬럼들 중 NAME만 출력되도록 하라는 문제. WHERE절에 조건을 주어 SELECT ~ FROM ~ WHERE의 기본 형태로 풀어주면 간단히 문제해결. SELECT NAME FROM CITY WHERE POPULATION >= 120000 AND COUNTRYCODE = 'USA'; Select All 문제:..
2021.07.13