197. Rising Temperature

2022. 6. 3. 13:39· 자료구조 알고리즘/코딩테스트

https://leetcode.com/problems/rising-temperature/

 

Rising Temperature - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

select a.id as Id
from Weather as a
join Weather as b
on DATEDIFF(a.recordDate, b.recordDate) = 1 and a.temperature > b.temperature

solution comment 에는 id 를 가지고 하는 것도 있었다.

어제 오늘의 경우 id가 하나 차이가 나니까.

solution에 나오기로는 join 과 datediff 를 사용하는 것이 핵심이라고 한다.

나는 datediff 를 모르고 +1 연산으로만 했었는데 이 방법은 mysql에서는 안 된다고 한다.

그리고 datediff(내일, 오늘) = 1 이런 식으로 해야 양수로 나온다. 앞의 인자가 더 뒤의 날짜로.

best

SELECT w2.Id  FROM Weather w1,Weather w2 
WHERE w2.recordDate = DATE_ADD(w1.recordDate, INTERVAL 1 DAY) 
AND w2.Temperature > w1.Temperature;
728x90
반응형

'자료구조 알고리즘 > 코딩테스트' 카테고리의 다른 글

1741. Find Total Time Spent by Each Employee  (0) 2022.06.09
607. Sales Person  (0) 2022.06.03
1148. Article Views I  (0) 2022.06.03
1581. Customer Who Visited but Did Not Make Any Transactions  (0) 2022.06.03
746. Min Cost Climbing Stairs  (0) 2022.05.31
'자료구조 알고리즘/코딩테스트' 카테고리의 다른 글
  • 1741. Find Total Time Spent by Each Employee
  • 607. Sales Person
  • 1148. Article Views I
  • 1581. Customer Who Visited but Did Not Make Any Transactions
내공얌냠
내공얌냠
내공냠냠
내공얌냠
내공냠냠
내공얌냠
전체
오늘
어제
  • 분류 전체보기 (254)
    • 개발 (113)
      • mediapipe (16)
      • insightface (5)
      • JongjuAR (3)
    • 자료구조 알고리즘 (79)
      • 코딩테스트 (64)
      • 이론 (15)
    • 공부 (7)
      • 단행본 (7)
      • 튜토리얼 (19)
      • 논문 (15)
      • 복기 (5)
    • 참여 (5)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • 미디어파이프
  • kubeflow설치안됨
  • speaker adaptation tts
  • 음성인식 튜토리얼
  • vscode 스프링 설치
  • git tutorial
  • 머신러닝이란
  • flutter
  • postgresql install in mac
  • torchscript vs onnx vs tensorrt
  • 구글 미디어파이프
  • 컴퓨터 비전 기초
  • 깃 튜토리얼
  • 플러터 튜토리얼
  • flutter 행사
  • flutter 행사 후기
  • mediapipe
  • kubeflow설치가이드
  • mediapipe translate
  • flutter conference
  • ios google places api
  • 컴퓨터 비전 책 추천
  • flutter tutorial
  • google mediapipe
  • 딥러닝 기반 음성인식 기초
  • 음성인식 기초
  • python telegrambot
  • 플러터
  • postgresql 재설치
  • 컴퓨터 비전

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
내공얌냠
197. Rising Temperature
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.