Giter Site home page Giter Site logo

algorithm-study's Introduction

💻알고리즘 해결한 문제들💻

Level Problem number
😃튼튼 기본기😃 1292
1978 2309 2460 2501 2581 2609 2693 3460 10818 10870 DFS와BFS(1260)
평균은 넘겠지(4344)
RGB거리(1149)
국영수(10825) lambda함수
상근이의 여행(9372) BFS
👍약점 체크👍 가르침(1062)
인구이동(16234) BFS 이용한 문제 풀이
이차원 배열과 연산(17140) Collections-Counter
운동(1956) 플로이드워셜

참고 자료

Level Problem number
😃코딩테스트 연습😃 크레인 인형 뽑기
43165
42746
42748
42897
42898
42626
42577
42578
😃Weekly Challenge😃 1주차
👍SQL👍 LEVEL1
59034
59035
59036
59037
59039
59403
59404
59405
59407
59415
59038
LEVEL2
Level Problem number
코딩테스트연습 길찾기(다이아몬드)
약수개수세기
완전수
숫자뒤집기

mysql (MariaDB 쿼리 문법 정리)

  • DATE_FORMAT(날짜,형식) : 날짜를 지정한 형식으로 출력
    형식은 '%Y %m %d' 사용
    hour(시간데이터)로 시간 접근 가능
  • SET @변수이름 := 초기값;
  • NULL 처리하기
    NULL값 채우기 IFNULL(변수,'대체 값')
    변수 IS NULL (or 변수 IS NOT NULL)
  • 출력 개수는 limit로 제한 ex) order by 변수 limit 개수
    3번째 row부터 11번째 row까지 조회 Limit 2,10;
  • 데이터 개수, 카운트(COUNT) ex) count(*) 전체 개수, COUNT(컬럼) 특정 컬럼의 개수
  • 글자 비교는 like ex) 변수 like 'happy%' -- 앞글자가 happy로 시작하는 단어
    '%happy' 끝부분이 happy인 경우, '%happy%' happy가 들어간느 모든 값
  • 특정 컬럼을 그룹화 하는 GROUP BY, 특정 컬럼을 그룹화한 결과에 조건을 거는 HAVING
    WHERE은 그룹화 하기 전, HAVING은 그룹 후 조건
SELECT DATE_FORMAT(DATETIME,'%H') AS H, COUNT(DATETIME)
FROM ANIMAL_OUTS
GROUP BY H
HAVING H BETWEEN 9 AND 19
ORDER BY H
SET @TIME := -1;
SELECT (@TIME := @TIME + 1), (SELECT COUNT(*) FROM ANIMAL_OUTS WHERE HOUR(DATETIME) = @TIME)
FROM ANIMAL_OUTS
WHERE @TIME <23
SET ANIMAL_INS.ANIMAL_ID, ANIMAL_INS.DATETIME
FROM ANIMAL_INS
WHERE ANIMAL_INS.ANIMAL_ID NOT IN (SELECT ANIMAL_ID FROM ANIMAL_OUTS)
ORDER BY ANIMAL_INS.DATETIME
LIMIT 3;

LIKE

SELECT *
FROM STUDENT
WHERE STUDENT_ID like 'a%'

LIKE 'a%' a로 시작하는 모든 값
LIKE 'a_%_%' a로 시작되고 최소 3이상 길이를 가진 값
LIKE '_a%' 두번쨰 자리가 a인 모든 값

Between

where 절 내 검색 조건으로 범위를 지정하고자 할 때

select *
from products
wher price between 10 and 20

select *
from products
where price not between 10 and 20

중복 제거 (DISTINCT, GROUP BY)

SELECT COUNT(DISTINCT NAME) AS NAME_COUNT 
FROM ANIMAL_INS 
WHERE NAME IS NOT NULL

SELECT COUNT(NAME) 
FROM ANIMAL_INS
WHERE NAME IS NOT NULL
GROUP BY NAME;

JOIN 구문

1. INNER JOIN 구문

tabel1, table2의 일치되는 same_feature 내용을 가져온다

select table1.name, tabel2.date
from table1
inner join table2
on tabel1.same_feature = tabel2.same_feature
oreder by tabel1.name;
2. LEFT JOIN 구문(LEFT를 포함한 교집합)

tabel1을 기준으로 table2의 일치되는 same_feature 내용을 table1 뒤에 붙이고 불일치 데이터는 NULL 채움

select *
from table1
left join table2
on tabel1.same_feature = tabel2.same_feature
3. RIGHT JOIN 구문(RIGHT를 포함한 교집합)

tabel2을 기준으로 table1의 일치되는 same_feature 내용을 table1 뒤에 붙이고 불일치 데이터는 NULL 채움
right join table => talbe을 중심으로

select *
from table1
right join table2
on tabel1.same_feature = tabel2.same_feature

CASE WHEN 구문

select col1, col2, case when 조건1 then 값1 when 조건2 then 값2 else 값3 end as 새로운 컬럼 이름
from table1

-- 조건에 포함되지 않는 경우만 다른 when으로 내려감! 
select *,(
  case
     when size < 10 then 'small'
     when size < 30 then 'medium'
     when size < 50 then 'large'
     else 'extra'
  end) as '크기'
from datatable

algorithm-study's People

Contributors

eeun-ju avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.