气死爹了 用C++过不去 换成Java 过了
一:题目
二:上码
class Solution {public int minimumLines(int[][] stockPrices) {Arrays.sort(stockPrices,(o1,o2)->o1[0]-o2[0]);int n = stockPrices.length;if (n == 1) return 0;int ans = 1;for (int i = 0; i < n-2; i++) {int k1 = stockPrices[i+1][0] - stockPrices[i][0];int k2 = stockPrices[i+1][1] - stockPrices[i][1];int k3 = stockPrices[i+2][0] - stockPrices[i+1][0];int k4 = stockPrices[i+2][1] - stockPrices[i+1][1];if (k2*k3 != k1 * k4) ans++;}return ans;}
}