【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 ...
 
随机推荐
- (十一)会话跟踪技术之作用域(request、session、servletContext)
			
一.作用域范围 Request 保存的键值仅在下一个request对象中可以得到,作用于两个有请求关系的页面 Session 它是一个会话范围,相当于一个局部变量,从Sess ...
 - eclipse spring3.X redis 整合-配置
			
花了一天时间折腾redis的配置 用到的jar spring 3.1.1 aopalliance-1.0.jar commons-pool2-2.3.jar jedis-2.7.2.jar sprin ...
 - 【Leetcode_easy】762. Prime Number of Set Bits in Binary Representation
			
problem 762. Prime Number of Set Bits in Binary Representation solution1: class Solution { public: i ...
 - MOQ中CallBase的作用
			
当使用Moq来Mock一个具体的类,类里的方法为virtual时,Moq会将当前类,所有的virtual方法默认重写成空实现. 如果我们想要访问真实的代码,有两种方法 1.在创建Mock时,设置Cal ...
 - react用redux 做的todolist
			
### 1. 创建项目 create - react - app 项目名(shop) ### 2. 进入项目,下载redux cnpm install redux --save ### 3. ...
 - 【Aizu - 0189】Convenient Location (最短路 Floyd算法)
			
Convenient Location 直接翻译了 Descriptions 明年毕业的A为就业而搬家.就职的公司在若干城市都有办公室,不同天出勤的办公室也不同.所以A在考虑住在哪去各个办公室的时长最 ...
 - golang web框架 beego 学习 (七)json转数组
			
Modules type User struct { Id int64 `json:"id"` Name string `json:"name"` Email ...
 - 【miscellaneous】关于gst ffmpeg插件的安装心得
			
1 一直通过软件源不能将ffmpeg插件进行安装 2 下载源码编译一直失败 说是需要依赖bad插件 3 bad插件安装不上在ubuntu下 解决办法: 应该直接查找ffmpeg插件的安装办法,不是只有 ...
 - Nginx基本使用方法
			
原帖:http://zyjustin9.iteye.com/blog/2017394 相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人 ...
 - go打印九九乘法表
			
package main import ( "fmt" ) func main() { for i := 1; i < 10; i++ { for j := 1; j < ...