题目如下:

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. Python Django的安装配置

    学习Django前,我们要确定电脑上是否已经安装了Python,目前Python有两个版本,不过这两个版本并不互相兼容,所以根据个人选择合适的版本. 因为从Django2.0开始将不再支持Python ...

  2. Cannot read property 'type' of undefined ....

    一直解决不了,弄了半天是 jquery 版本太低,换一个版本就ok.

  3. Python分析《武林外传》 -----转载

    转载原链接:http://www.cnblogs.com/fredkeke/p/8328387.html 我一向比较喜欢看武侠电影.小说,但是06年武林外传开播的时候并没有追剧,简单扫几眼之后发现他们 ...

  4. WPF Good UI 2

    自定义一个漂亮的window窗口UI <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation& ...

  5. 《Python Data Structures》 Week4 List 课堂笔记

    Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week4 List 8.2 Manipulating Lists 8 ...

  6. bash shell:获取当前脚本的绝对路径(pwd/readlink)

    有时候,我们需要知道当前执行的输出shell脚本的所在绝对路径,可以用dirname实现. 我们知道 dirname 可以获取一个文件所在的路径,dirname的用处是: 输出已经去除了尾部的”/”字 ...

  7. 练习4-python+selenium+pandas

    最近对于python的第三方库pandas比较有兴趣,在学习的过程中也简单的结合selenium做了一个简单的小工具 最新公司用一个外部系统来记录,追踪BUG,可是这个系统并不是专业的BUG管理系统, ...

  8. python函数及调用

    python的函数是一段重复多次可调用的代码,依据python的函数,我们可以利用函数式的编程,来减少代码的重复. 在本章节中,详细的介绍python的函数,以及python的函数式编程的与众不同,函 ...

  9. VMWARE 克隆步骤

    克隆linux服务器点击设置 ->网络适配器->高级->MAC地址 重新生成一个 OK

  10. 编码总结一:Java默认字符集

    (一)JVM默认字符集——Charset.defaultCharset() 获取Java虚拟机默认字符集,该字符集默认跟操作系统字符集一致,也可以通过-Dfile.encoding="GBK ...