原题

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的更多相关文章

  1. 【LeetCode】120. Triangle 解题报告(Python)

    [LeetCode]120. Triangle 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址htt ...

  2. 【LeetCode】120 - Triangle

    原题:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacen ...

  3. 【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 ...

  4. 【leetcode】Valid Triangle Number

    题目: Given an array consists of non-negative integers, your task is to count the number of triplets c ...

  5. 【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 ...

  6. 【LeetCode】Pascal's Triangle II 解题报告

    [LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...

  7. 【LeetCode】数学(共106题)

    [2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/979 ...

  8. 【动态规划】The Triangle

    问题 E: [动态规划]The Triangle 时间限制: 1 Sec  内存限制: 128 MB提交: 24  解决: 24[提交][状态][讨论版] 题目描述 73 88 1 02 7 4 44 ...

  9. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

随机推荐

  1. Core Data 的线程安全问题

    前言: 很多小的App只需要一个ManagedContext在主线程就可以了,但是有时候对于CoreData的操作要耗时很久的,比如App开启的时候要载入大量数据,如果都放在主线程,毫无疑问会阻塞UI ...

  2. Scratch3架构结构说明

    Scratch3.0整体项目结构比较庞大,对于不同二次开发开始的时候会出现一头雾水,需要先了解下整体框架,可以按需要在指定的源码下进行修改,大致结构如下: 1. scratch-gui: 是基于Rea ...

  3. Zabbix部分监控指标

    MySQL请求流量带宽.MySQL响应流量带宽.CPU使用率.内存利用率.网卡流量等.

  4. Linux IO的五种模型 ongoing

    服务器端编程经常需要构造高性能的IO模型,常见的IO模型: 阻塞I/O模型  (Blocking IO) ------------(同步)(阻塞) 非阻塞I/O模型 (Non-Blocking IO) ...

  5. 系统获取 IP 工具类

    系统获取 IP 工具类 import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterf ...

  6. HttpClient的几种请求方式

    public static String doPostToken(String tokenUrl,String clientId,String clientSecret,String grantTyp ...

  7. python基础学习记录......

    1.IDEA写python 打开IDEA,File--->settings---->Plugins    输入python  安装   重启IDEA 2.新建Project     选择P ...

  8. (十一)El表达式详细介绍

    看之前,最好先看下 el表达式快速入门 本来将重点讲下 el表达式 能干嘛 : 目录 执行计算 获得 web 开发常用对象 关于 param 与 paramValues 的用法: 关于 header ...

  9. SecureCRT SSH 失败 Key exchange failed 解决方法

    背景:SecureCRT 的SSH正常使用过程中,突然出现: Key exchange failed. No compatible hostkey.The server supports these ...

  10. 3种PHP实现数据采集的方法

    https://www.php.cn/php-weizijiaocheng-387992.html