public boolean isConvex(List<List<Integer>> points) {
long curCrossProduct = 0;
long preCrossProduct = 0;
for (int i = 0; i < n; i++) {
List<Integer> pointA = points.get(i);
List<Integer> pointB = points.get((i + 1) % n);
List<Integer> pointC = points.get((i + 2) % n);
curCrossProduct = getCrossProduct(pointA, pointB, pointC);
if (curCrossProduct != 0) {
if (curCrossProduct * preCrossProduct < 0) {
preCrossProduct = curCrossProduct;
public int getCrossProduct(List<Integer> pointA, List<Integer> pointB, List<Integer> pointC) {
int BAx = pointB.get(0) - pointA.get(0);
int BAy = pointB.get(1) - pointA.get(1);
int CAx = pointC.get(0) - pointA.get(0);
int CAy = pointC.get(1) - pointA.get(1);
return BAx * CAy - CAx * BAy;