![]() |
VOOZH | about |
Given N triangles along with the length of their three sides as a, b and c. The task is to count the number of unique triangles out of these N given triangles. Two triangles are different from one another if they have at least one of the sides different.
Examples:
Input: arr[] = {{3, 1, 2}, {2, 1, 4}, {4, 5, 6}, {6, 5, 4}, {4, 5, 6}, {5, 4, 6}};
Output: 3Input: arr[] = {{4, 5, 6}, {6, 5, 4}, {1, 2, 2}, {8, 9, 12}};
Output: 3
This problem has been solved using ordered set of STL in the previous post. Approach: We will be discussing the operator overloading based approach to solve this problem where we are going to overload the relational operator (==) of our class.
Below is C++ implementation of the above approach:
4
Time Complexity:O(N)Auxiliary Space:O(1)