Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: Consider the sequence 1, 4, 9, 16, … of perfect squares. What is the smallest square that is greater than 500 and also ends in the digit 6?
- A. 576
- B. 676
- C. 529
- D. 256
Correct answer: A. 576
Squares above 500: 529, 576, …; 24² = 576 ends in 6. 676 = 26² is the next one, 529 ignores the last-digit rule, and 256 ends in 6 but is below 500.
More Coding Interview Problems questions
- Problem: How many 4-letter strings over {A, B, C} have no letter appearing more than twice?
- Problem: The binary tree with root 10, left child 5, right child 15, and 5 having right child 7, 15 having left child 12, is traversed in…
- Problem: A list starts as [8, 3, 5]. Three insertion steps add the numbers 4, 9, 1 at the front of the list (each is inserted at index 0)…
- Problem: A deque starts as [2, 4, 6]. The operations are: push front 1, push back 8, pop front, push back 3. What is the sum of the final…
- Problem: The string "tenet" is considered. How many of its substrings (by index range, length at least 2) are palindromes?
- Problem: Water fills a 1-dimensional container with walls of heights [4, 1, 3, 1, 2]. Each cell holds water up to the minimum of the…