Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: For the words ["bella", "label", "roller", "dinner", "ladder"], how many pairs (i, j) with i < j are anagrams of each other (same letters, same counts)?
- A. 2
- B. 0
- C. 3
- D. 1
Correct answer: D. 1
Anagram pairs share a sorted-letter signature. Comparing lengths alone or the first letters gives a wrong pair count.
More Coding Interview Problems questions
- Problem: The number 2024 is factorised. How many positive integers less than 10000 are divisors of 2024 × 2025?
- Problem: How many subarrays of [1, 2, 3, 1, 2, 3, 4] contain exactly 3 distinct values? Run the brute-force code. python a = [1, 2, 3, 1…
- Problem: How many integers in [1, 1000] are divisible by 7, 11 or 13? Run the code. python print(sum(1 for x in range(1, 1001) if x % 7 ==…
- Problem: What is the number of trailing zeros in 2025! (in decimal)? Run the code. python n = 2025 c = 0 p = 5 while p <= n: c += n // p p…
- Problem: What is the sum of all distinct prime factors of 2025? Run the code. python n = 2025 f = 2 ps = set() while f f <= n: while n % f…
- Problem: How many integers x in [1, 500] have x^2 + x + 41 prime? Run the code. python def isp(n): return n > 1 and all(n % d for d in…