As reported: Dell Technologies Java backend interview (2026), round 1 (DSA + Java): given an integer array, find all Pythagorean triplets, e.g. (3, 4, 5); the same round also asked for the first non-repeated character of a string.
Given an array nums of positive integers, return all distinct triplets [a, b, c] of values taken from three different positions of the array such that a² + b² = c².
Write each triplet with a < b < c (for positive integers, a = b is impossible), and return the list sorted in increasing order of a, then b, then c. Each distinct triplet appears once, even if the array contains repeated values.
Example 1
nums = [3,1,4,6,5]
Output: [[3,4,5]]
Example 2
nums = [10,4,6,12,5,8,13,3]
Output: [[3,4,5],[5,12,13],[6,8,10]]
Example 3
nums = [5,5,3,4,4]
Output: [[3,4,5]]
Repeated values still give one triplet.
Constraints: 1 ≤ nums.length ≤ 2000; 1 ≤ nums[i] ≤ 10^4.
Code runner format: one JSON line: nums. Implement pythagoreanTriplets(nums).