Online C++ Compiler

#include <bits/stdc++.h> using namespace std; class Solution { public: bool isConvex(vector<vector<int>>& points) { bool neg = false; bool pos = false; int n = points.size(); for(int i = 0; i < n; i++){ int a = i; int b = (i + 1) % n; int c = (i + 2) % n; int crossProduct = calc(points[a][0], points[a][1], points[b][0], points[b][1], points[c][0], points[c][1]); if(crossProduct < 0) neg = true; else if(crossProduct > 0) pos = true; if(neg && pos) return false; } return true; } int calc(int ax, int ay, int bx, int by, int cx, int cy){ int BAx = ax - bx; int BAy = ay - by; int BCx = cx - bx; int BCy = cy - by; return (BAx * BCy - BAy * BCx); } }; main(){ vector<vector<int>> v = {{0,0},{0,1},{1,1},{1,0}}; Solution ob; cout << (ob.isConvex(v)); }