【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 ...
随机推荐
- pytorch0.4.1安装
pytorch官网:https://pytorch.org/ 这里安装pytorch0.4.1版本(最新版本为1.3.0系列,但是在跑github上的一些项目时会不断地报“ UseWarinig:Le ...
- (三)表单与servlet的初步结合
一.form表单基本使用 <form>标签可创建一个表单,属性如下: <form>标签子标签可以有如下: <input> : 用于搜集用户信息. <input ...
- 怎么用Ubuntu系统制作Ubuntu系统盘
ubuntu 16 下载地址: http://releases.ubuntu.com/16.04/?_ga=2.211639766.273896083.1564759714-49163328.1564 ...
- iOS-收起键盘
1 除了调用相应控件的resignFirstResponder方法外,还有另外三种办法: 2 重载UIViewController中的touchesBegin方法,然后在里面执行在[self.view ...
- elasticsearch7.1.1【win】下载安装
下载:https://www.elastic.co/cn/downloads/elasticsearch 历史版本下载:https://www.elastic.co/cn/downloads/past ...
- 解决maven打包时,会编译特定文件导致文件不可用
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resou ...
- linux中LVM介绍及实验过程
LVM LVM这个词不仅一次出现过,在安装Centos时,磁盘分区时,默认分区就是使用LVM方式分区:再一个就是在OpenStack部署时候用到LVM作为后端存储.对LVM的理解还是不太清晰,查询资料 ...
- hdoj3336(kmp算法next数组的应用)
题目链接:https://vjudge.net/problem/HDU-3336 题意:给定长为n(<=2e5)的字符串s,求s的每个前缀在s中出现的次数之和. 思路: 用dp[i]表示以s[i ...
- element form 校验数组每一项
1.校验的数据结构如下: 2.html结构 <el-dialog :title="title" :visible.sync="visable" width ...
- [转帖]从光刻机的发展,看懂ASML为何是不可取替
从光刻机的发展,看懂ASML为何是不可取替 http://mini.eastday.com/mobile/171230223351249.html# 2017-12-30 22:33 来源:半导 ...