2475. Number of Unequal Triplets in Array 發表於 2023-02-13 | 分類於 leetcode problemsolutionsolution 11234567891011121314151617181920class Solution {public: int unequalTriplets(vector<int>& nums) { // 2 3 4 4 4 sort(nums.begin(), nums.end()); int n = nums.size(); if(n<3) return 1; int count =0; for(int i=0;i<n-2;i++){ for(int j=i+1;j<n-1;++j){ for(int k = j+1;k<n;++k){ if(nums[i]!=nums[j] && nums[j]!=nums[k]) count++; } } } return count; }}; analysis sloution 1 time complexity O(n^3) space complexity O(1) solution 2 time complexity O()