Zheaoli / do-something-right

MIT License
37 stars 3 forks source link

2022-06-08 #262

Open Zheaoli opened 2 years ago

Zheaoli commented 2 years ago

2022-06-08

SaraadKun commented 2 years ago

1037. 有效的回旋镖

class Solution {
    public boolean isBoomerang(int[][] points) {
        int k1 = (points[1][0] - points[0][0]) * (points[2][1] - points[0][1]);
        int k2 = (points[2][0] - points[0][0]) * (points[1][1] - points[0][1]);
        return k1 != k2;
    }
}

WeChat: Saraad

dreamhunter2333 commented 2 years ago
package main

import "fmt"

/*
 * @lc app=leetcode.cn id=1037 lang=golang
 *
 * [1037] 有效的回旋镖
 */

// @lc code=start
func isBoomerang(points [][]int) bool {
    return (points[1][0]-points[0][0])*(points[2][1]-points[1][1]) != (points[1][1]-points[0][1])*(points[2][0]-points[1][0])
}

// @lc code=end
func main() {
    fmt.Println(isBoomerang([][]int{{1, 1}, {2, 3}, {3, 2}}))
    fmt.Println(isBoomerang([][]int{{1, 1}, {2, 2}, {3, 3}}))
}

微信id: 而我撑伞 来自 vscode 插件