반응형
https://leetcode.com/problems/triangle-judgement/description/
Triangle Judgement - LeetCode
Can you solve this real interview question? Triangle Judgement - Table: Triangle +-------------+------+ | Column Name | Type | +-------------+------+ | x | int | | y | int | | z | int | +-------------+------+ (x, y, z) is the primary key column for this ta
leetcode.com
case문을 사용해본 문제였습니다.
📕 풀이방법
📔 풀이과정
삼각형의 조건은 한 변 < 나머지 두 변의 합입니다. 따라서 그렇지 못하다면 No를 아니라면 Yes를 case문으로 정의해 해당 column명을 trangle로 select하면 됩니다.
📕 Code
📔 MySQL & Oracle
select x, y, z,
case when
x >= y + z or y >= x + z or z >= x + y then 'No'
else
'Yes'
end as triangle
from triangle
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - LeetCode (easy) 657. Robot Return to Origin (0) | 2023.06.02 |
---|---|
(C++) - LeetCode (easy) 645. Set Mismatch (0) | 2023.06.01 |
(C++) - LeetCode (easy) 605. Can Place Flowers (0) | 2023.05.17 |
(C++) - LeetCode (easy) 566. Reshape the Matrix (0) | 2023.04.25 |
(C++) - LeetCode (easy) 551. Student Attendance Record I (0) | 2023.04.18 |