Trains the technique from
LeetCode 1925Count Square Sum TriplesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Return how many ordered triples (a, b, c) of whole numbers between 1 and n satisfy a * a + b * b == c * c.
Triples in a different order count separately, so (3, 4, 5) and (4, 3, 5) are two of them.
Example 1
Three pairs of legs work within thirteen, each counted twice for its two orders: 3 with 4, 6 with 8, and 5 with 12.
Example 2
Two pairs work within twelve, 3 with 4 and 6 with 8, each counted twice.
Example 3
Nothing within four works at all.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_triples(n: int) -> int:public int countTriples(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.