Pergunta de entrevista da empresa Amazon

Describe an algorithm to find pythagorean triplets given an array of n integers.

Resposta da entrevista

Sigiloso

25 de mai. de 2012

For every pair of numbers (a,b) in the array put a^2+b^2 into a hashmap. Iterate over the array again, for every element c check if c^2 is in the hashmap, if it is you found a tripplet. O(n^2) runtime.

1