03. Pythagorean Triplet
Last updated
Last updated
class Solution {
public:
bool checkTriplet(int arr[], int n) {
unordered_set<int> s;
for (int i = 0; i < n; ++i)
s.insert(arr[i] * arr[i]);
for (auto a : s) {
for (auto b : s) {
if (s.find(a + b) != s.end())
return true;
}
}
return false;
}
};