Growth ๐ŸŒณ/Practice ๐Ÿ’ป

[Leet code] 610. Triangle Judgement

์ธ” 2023. 9. 13. 15:19

๐Ÿ“ข ๋ณธ ํฌ์ŠคํŒ…์— ํ™œ์šฉ๋˜๋Š” ๊ธฐ๋ณธ ๋ฌธ์ œ ๋ฐ ์ž๋ฃŒ ์ถœ์ฒ˜๋Š”

       ๋ฆฌํŠธ์ฝ”๋“œ Problems, https://leetcode.com/problemset/all/์ž„์„ ๋ฐํž™๋‹ˆ๋‹ค.


โœ”๋ฌธ์ œ

https://leetcode.com/problems/triangle-judgement/description/

 

LeetCode - The World's Leading Online Programming Learning Platform

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

Table : Triangle

Report for every three line segments whether they can form a triangle.

Return the result table in any order.

The result format is in the following example.


โœ” ํ’€์ด

  ๋ฌธ์ œ ์š”๊ตฌ์‚ฌํ•ญ  

 

์‚ผ๊ฐํ˜• ํ˜•์„ฑ ์กฐ๊ฑด์„ ์•Œ์•„๋ณด๋ฉด,

'๊ฐ€์žฅ ๊ธด ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ๋‚˜๋จธ์ง€ ๋‘ ๋ณ€์˜ ๊ธธ์ด์˜ ํ•ฉ๋ณด๋‹ค ์ž‘์•„์•ผ ํ•œ๋‹ค.'

์ด๊ฒƒ์„ ์ฟผ๋ฆฌ๋กœ ์ž‘์„ฑํ•ด์ค˜์•ผํ•˜๋Š”๋ฐ ์„ธ ๋ณ€์ธ x, y, z ์ค‘ ์ตœ๋Œ€ ๊ธธ์ด๋ฅผ ๊ฐ™๋Š” ๋ณ€์ด ์–ด๋–ค ์ปฌ๋Ÿผ์ธ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์—AND์กฐ๊ฑด์„ ์‚ฌ์šฉํ•ด์„œ ๊ฒฝ์šฐ์˜ ์ˆ˜๋ฅผ ๋ชจ๋‘ ์กฐ๊ฑด์œผ๋กœ ์จ์คฌ๋‹ค.

SELECT x, y, z,
    CASE WHEN (x+y > z AND y+z > x AND z+x > y) THEN 'Yes' ELSE 'No' END AS triangle
 FROM Triangle