题目如下:

boomerang is a set of 3 points that are all distinct and not in a straight line.

Given a list of three points in the plane, return whether these points are a boomerang.

Example 1:

Input: [[1,1],[2,3],[3,2]]
Output: true

Example 2:

Input: [[1,1],[2,2],[3,3]]
Output: false

Note:

  1. points.length == 3
  2. points[i].length == 2
  3. 0 <= points[i][j] <= 100

解题思路:本题就是判断三点是否在一条直线上,判断的方法也很简单,任意从这三个点中选取两组点对,如果这两组的点对的斜率相同,则在同一直线上。

代码如下:

class Solution(object):
def isBoomerang(self, points):
"""
:type points: List[List[int]]
:rtype: bool
"""
return (points[0][1]-points[1][1]) * (points[1][0]-points[2][0]) \
!= (points[0][0]-points[1][0]) * (points[1][1]-points[2][1])

【leetcode】1037. Valid Boomerang的更多相关文章

  1. 【LeetCode】1037. Valid Boomerang 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 中学数学题 日期 题目地址:https://leet ...

  2. 【Leetcode_easy】1037. Valid Boomerang

    problem 1037. Valid Boomerang 参考 1. Leetcode_easy_1037. Valid Boomerang; 完

  3. 【LeetCode】36. Valid Sudoku 解题报告(Python)

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

  4. 【LeetCode】593. Valid Square 解题报告(Python)

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

  5. 【LeetCode】678. Valid Parenthesis String 解题报告(Python)

    [LeetCode]678. Valid Parenthesis String 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人 ...

  6. 【LeetCode】65. Valid Number

    Difficulty: Hard  More:[目录]LeetCode Java实现 Description Validate if a given string can be interpreted ...

  7. 【LeetCode】680. Valid Palindrome II

    Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...

  8. 【leetcode】36. Valid Sudoku(判断能否是合法的数独puzzle)

    Share Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated accordi ...

  9. 【LeetCode】941. Valid Mountain Array 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

随机推荐

  1. Junit单元测试的使用

    这里拿Dynamic Web Project项目来演示,首先创建一个Dynamic Web Project项目,起名,点next, 继续点next, 将web.xml文件勾选,finish, 接下来在 ...

  2. Delphi XE2 之 FireMonkey 入门(8) - TImage

    TImage 主要成员: { 属性 } Bitmap              : TBitmap;        //图像 BitmapMargins        : TBounds;      ...

  3. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_07 缓冲流_3_BufferedInputStream_字节缓冲

    内容改成abc 来个数组缓冲

  4. 写Rust的感觉

    以前写代码,像是学会了语言规则,可以在不违反规则的情况下,随便使用特性,这个世界就是你的了. 写Rust,就像是一个法律文本,编译器像是一个法官. 你只能在法律容许的情况下,做事情,更法官很严格,在编 ...

  5. 机器学习--如何将NLP应用到深度学习(3)

    数据收集以后,我们下面接着要干的事情是如何将文本转换为神经网络能够识别的东西.   词向量 作为自然语言,只有被数学化才能够被计算机认识和计算.数学化的方法有很多,最简单的方法是为每个词分配一个编号, ...

  6. DFS序1

    给一棵有根树,这棵树由编号为1..N的N个结点组成.根结点的编号为R.每个结点都有一个权值,结点i的权值为vi .接下来有M组操作,操作分为两类:1 a x,表示将结点a的权值增加x:2 a,表示求结 ...

  7. [10期]浅谈SSRF安全漏洞

    引子:SSRF 服务端请求伪造攻击 很多web应用都提供从其他服务器上获取数据的功能.使用用户指定的URL,web应用可以从其他服务器获取图片,下载文件,读取文件内容等. 这个功能被恶意使用的话,可以 ...

  8. [LeetCode] 834. Sum of Distances in Tree

    LeetCode刷题记录 传送门 Description An undirected, connected treewith N nodes labelled 0...N-1 and N-1 edge ...

  9. mooc-IDEA 列操作--005

    十一.IntelliJ IDEA -列操作 实例:根据HTTP请求JSON文件,生成一个枚举类 Step1:创建一个枚举类,把要转换的JSON串粘贴进来. 最终要实现效果 Step2:选中第一个100 ...

  10. jQuery架构设计与实现(2.1.4版本)

    市面上的jQuery书太多了,良莠不齐,看了那么多总觉得少点什么 对"干货",我不喜欢就事论事的写代码,我想把自己所学的知识点,代码技巧,设计思想,代码模式能很好的表达出来,所以考 ...