LeetCode 611, Medium. Topics: Array, Two Pointers, Binary Search, Greedy, Sorting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:
Problem
Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Examples
Constraints
- 1 <= nums.length <= 1000
- 0 <= nums[i] <= 1000
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026