【leetcode】610. Triangle Judgement
原题
A pupil Tim gets homework to identify whether three line segments could possibly form a triangle.
However, this assignment is very heavy because there are hundreds of records to calculate.
Could you help Tim by writing a query to judge whether these three sides can form a triangle, assuming table triangle holds the length of the three sides x, y and z.
| x | y | z |
|---|---|---|
| 13 | 15 | 30 |
| 10 | 20 | 15 |
For the sample data above, your query should return the follow result:
| x | y | z | triangle |
|---|---|---|---|
| 13 | 15 | 30 | No |
| 10 | 20 | 15 | Yes |
解析
给一组xyz,代表三角形的三边
写sql输出,判断三边是否能组成三角形
思路
我的思路本是想判断三边中最长的边是不是大于其余两边之和,但是太麻烦,可以直接三边都判断
解法
SELECT
x,
y,
z,
CASE
WHEN x + y > z AND x + z > y AND y + z > x THEN 'Yes'
ELSE 'No'
END AS 'triangle'
FROM
triangle
;
【leetcode】610. Triangle Judgement的更多相关文章
- 【LeetCode】120. Triangle 解题报告(Python)
[LeetCode]120. Triangle 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址htt ...
- 【LeetCode】120 - Triangle
原题:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacen ...
- 【LeetCode】120. Triangle (3 solutions)
Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to a ...
- 【leetcode】Valid Triangle Number
题目: Given an array consists of non-negative integers, your task is to count the number of triplets c ...
- 【Leetcode】Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...
- 【LeetCode】Pascal's Triangle II 解题报告
[LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...
- 【LeetCode】数学(共106题)
[2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/979 ...
- 【动态规划】The Triangle
问题 E: [动态规划]The Triangle 时间限制: 1 Sec 内存限制: 128 MB提交: 24 解决: 24[提交][状态][讨论版] 题目描述 73 88 1 02 7 4 44 ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
随机推荐
- python 中 logging 模块的 log 函数以及坑
记录下吧,一个日志的函数,但有个坑是在调用函数时需要先将函数实例化为一个变量,否则进入某个循环时会多次刷新日志: """ 日志模块 """ ...
- web 中常用的两种上传文件的方法总结
这里我们来总结整理一下常用的两种文件上传方式以及要注意的东西: 1.springmvc .MultipartFile 的上传方式. 2.org.apache.commons.fileupload 使用 ...
- 17-js观察者模式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- MySQL安装时出现的问题
mysql正常安装结束之后需要连接你所安装的数据库的时候出现下面的错误: Client does not support authentication protocol requested by se ...
- CDH建表字符集问题
登陆metadata数据库: show variables like 'character_set%'; alter database hivemeta default character set l ...
- 乐字节Java反射之三:方法、数组、类加载器和类的生命周期
本文承接上一篇:乐字节Java发射之二:实例化对象.接口与父类.修饰符和属性 继续讲述Java反射之三:方法.数组.类加载器 一.方法 获取所有方法(包括父类或接口),使用Method即可. publ ...
- 【转】sql server迁移到mysql
SQL Server转换为MySQL工具,用了一下 感觉蛮不错的. 下载地址:https://www.jb51.net/softs/209207.html#downintro2 分享上来,同时也以便记 ...
- IdentityServer4 学习一
网上找的关于IdentityServer4的百度脑图 http://naotu.baidu.com/file/75b251257ce27cfa62e0ad7f47b75576?token=e2db61 ...
- Redis 常用命令学四:集合类型命令
1.增加和删除命令 127.0.0.1:6379> SADD st a (integer) 1 127.0.0.1:6379> SADD st r f g (integer) 3 127. ...
- MySQL提供的几种检索行数据的优化方式
ICP(Index Condition Pushdown): 在MySQL5.6之前,存储引擎会通过遍历索引定位基表中 的行,然后返回给Server层,再去为这些数据进行WHERE后的条件过滤.MyS ...