You are given a positive integer array sides of length 3.
Determine if there exists a triangle with positive area whose three side lengths are given by the elements of sides.
If such a triangle exists, return an array of three floating-point numbers representing its internal angles (in degrees), sorted in non-decreasing order. Otherwise, return an empty array.
Answers within 10^-5 of the actual answer will be accepted.
classSolution { public: vector<double> internalAngles(vector<int>& sides){ sort(sides.begin(), sides.end()); double a = sides[0], b = sides[1], c = sides[2]; if (a + b <= c) return {}; constdouble PI = acos(-1.0); auto getAngle = [&](double x, double y, double z) { double v = (y * y + z * z - x * x) / (2.0 * y * z); v = max(-1.0, min(1.0, v)); returnacos(v) * 180.0 / PI; }; vector<double> res = { getAngle(a, b, c), getAngle(b, a, c), getAngle(c, a, b) }; sort(res.begin(), res.end()); return res; } };