-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2475.数组中不等三元组的数目.cpp
executable file
·61 lines (55 loc) · 1.12 KB
/
2475.数组中不等三元组的数目.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* @lc app=leetcode.cn id=2475 lang=cpp
* @lcpr version=21909
*
* [2475] 数组中不等三元组的数目
*/
using namespace std;
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// @lc code=start
class Solution {
private:
vector<int> arr;
int cnt=0;
public:
int unequalTriplets(vector<int>& nums) {
this->arr=nums;
// sort(arr.begin(),arr.end());
for(int i=0;i+2<arr.size();i++)
{
for(int j=i+1;j+1<arr.size();j++)
{
if(arr[j]==arr[i])continue;
for(int k=j+1;k<arr.size();k++)
{
if(arr[k]==arr[j]||arr[k]==arr[i])continue;
cnt++;
}
}
}
return cnt;
}
};
// @lc code=end
/*
// @lcpr case=start
// [4,4,2,4,3]\n
// @lcpr case=end
// @lcpr case=start
// [1,1,1,1,1]\n
// @lcpr case=end
*/