FastPrepPythagorean Triple with Array Multiplicity
Problems/Pythagorean Triple with Array Multiplicity

Pythagorean Triple with Array Multiplicity

ByteDance logoByteDance● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report explicitly defines absolute-value equality and requires three distinct array occurrences, including multiplicity-sensitive zero cases.

You are given an integer array nums. Pick three entries at three different positions. Call their absolute values a, b, and c. Return whether some pick makes a * a + b * b = c * c true.

  • The sign of an entry does not matter, because a negative number has the same square as its absolute value.
  • Each position can be picked only once. So the same absolute value can show up more than once in your pick only if that many separate entries of the array have it.

Function

hasPythagoreanTriple(nums: int[]) → boolean

Examples

Example 1

nums = [3,-4,5,8]return = true

Pick the three entries whose absolute values are 3, 4, and 5. Then 9 + 16 = 25, so the answer is true.

Example 2

nums = [0,1,2]return = false

Using the zero would need two other entries with the same absolute value, because zero squared adds nothing. The array has only one zero, and no two entries share an absolute value. No other pick of three entries works either, so the answer is false.

Constraints

  • 0 <= nums.length <= 2000.
  • -1000000000 <= nums[i] <= 1000000000.

More ByteDance Onsite Interview questions

  • Search a Row- and Column-Sorted MatrixONSITE INTERVIEW · Seen Nov 2026
  • Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dynamic Median with Additions and DeletionsONSITE INTERVIEW · Seen Oct 2026
  • Serialize and Deserialize a String Key-Value StoreONSITE INTERVIEW · Seen Oct 2026
  • Binary Tree Maximum Path SumONSITE INTERVIEW · Seen Oct 2026
  • Merge Overlapping IntervalsONSITE INTERVIEW · Seen Oct 2026
  • Tic-Tac-Toe Move WinnersONSITE INTERVIEW · Seen Oct 2026
  • Kth Largest Element without a HeapONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Order Powers of Two and ThreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Top K Best-Selling Products in the Last N DaysAmazon · ONSITE INTERVIEW
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions

ByteDance interview experiences

  • ByteDance TikTok USDS SWE Intern Interview: 1 Experience
  • ByteDance MLE New Grad Interviews: 1 Experience
  • ByteDance Security SRE Intern Phone Screens: 1 Experience
  • ByteDance USDS New Grad SWE Phone Screen: 1 Experience
  • ByteDance New Grad Data Engineer Video Interviews: 1 Experience
  • ByteDance Trust & Safety Research Scientist Intern: 1 Experience
All ByteDance interview questionsSee ByteDance hiring insights
Saved
class Solution {
    public boolean hasPythagoreanTriple(int[] nums) {
        // TODO: use three distinct array occurrences.
    }
}
Checking account…