Dsa
Math
Easy
Triangle Count
Given an array of integers representing the lengths of sticks, count how many valid triangles can be formed using three different lengths. A set of lengths can form a triangle if the sum of the lengths of any two sides is greater than the length of the third side.
Input Format:
- A single line containing space-separated integers representing the lengths of the sticks.
Output Format:
- An integer representing the count of valid triangles.
Example:
Input:
3 4 5 1 2 6
Output:
4
Key concepts
geometrycombinatoricstriangle
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now