Data Structures & AlgorithmsModerateTCS NQT · CAT
Problem: The Euclidean distance squared between (1,2) and (4,6) is what integer?
- A. 5
- B. 7
- C. 49
- D. 25
Correct answer: D. 25
dx = 3 and dy = 4, so the squared distance is 9 + 16 = 25. Taking the square root gives 5, adding the differences gives 7, and squaring their sum gives 49.
More Coding Interview Problems questions
- Problem: In the sequence 2, 3, 5, 8, 12, 17, … each term increases by one more than the previous increase (differences 1, 2, 3, 4, …)…
- Problem: How many 4-element subsets of {1, 2, ..., 8} have a sum that is a multiple of 5?
- Problem: The array [4, 9, 16, 25] has its square roots summed. What is the sum of the square roots of these four numbers?
- Problem: A grid has 5 cells in a row, each painted red or blue. How many colourings have no two adjacent cells of the same colour?
- Problem: What is the largest integer n such that n! has at most 3 trailing zeros in base 10?
- Problem: The matrix [[2,0],[0,3]] is raised to the power 4 (matrix power). What is the sum of all entries of the result?