
Problem: 1534. 统计好三元组 Count Good Triplets用变量存储数组中的值防止多次访问IOCodeclass Solution { public: int countGoodTriplets(vectorint arr, int a, int b, int c) { int n arr.size(), a1, b1, c1, ans 0; for(int i 0; i n; i) { a1 arr[i]; for(int j i 1; j n; j) { b1 arr[j]; if(abs(a1-b1) a) { for(int k j 1; k n; k) { c1 arr[k]; if(abs(b1 - c1) b abs(a1-c1) c) ans; } } } } return ans; } };