Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: The mapping of letters is A=1 through Z=26. What is the sum of the values of the letters in the word "MATH"?
- A. 38
- B. 298
- C. 42
- D. 66
Correct answer: C. 42
M = 13, A = 1, T = 20, H = 8, total 42. Using 0-based positions gives 38, adding ASCII codes gives 298, and reversed positions (Z = 1) give 66.
More Coding Interview Problems questions
- Problem: The number of ways to choose 4 people from 9 so that a specific two people are never both chosen is what value?
- Problem: How many integers in [1, 10^4] are divisible by 3 and have an odd number of digits? Run the code. python print(sum(1 for x in…
- Problem: What is the number of distinct subsets sums obtainable from {2, 3, 7} (including the empty subset)? Run the code. python from…
- Problem: What is the largest prime factor of 2^20 - 1? Run the code. python n = 2 20 - 1 f = 2 last = 1 while f f <= n: while n % f == 0…
- Problem: How many numbers in [1, 500] are not divisible by 2, 3 or 5? Run the code. python print(sum(1 for x in range(1, 501) if x % 2 and…
- Problem: What is the number of inversions in the array [1, 3, 2, 5, 4, 6]? Run the code. python a = [1, 3, 2, 5, 4, 6] print(sum(1 for i…