본문 바로가기

Algorithm/Math

(C++) - LeetCode (easy) 1037. Valid Boomerang

반응형

https://leetcode.com/problems/valid-boomerang/description/

 

Valid Boomerang - LeetCode

Can you solve this real interview question? Valid Boomerang - Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang. A boomerang is a set of three points that are all distinct and

leetcode.com

직선의 기울기를 이용한 문제였습니다.

📕 풀이방법

📔 풀이과정


📕 Code

📔 C++

class Solution {
public:
    bool isBoomerang(vector<vector<int>>& points) {
        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]);
    }
};

*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.