Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: A text buffer contains "hello world". Each space is replaced by the three characters "%20" (URL-style encoding). What is the length of the resulting string?
- A. 11
- B. 13
- C. 12
- D. 14
Correct answer: B. 13
"hello world" has 11 characters and one space; replacing it with the 3 characters %20 adds 2, giving 13. 11 forgets the replacement, 12 counts %20 as 2 characters, and 14 adds 3 instead of 2.
More Coding Interview Problems questions
- Problem: The bitwise AND of all integers from 12 to 15 inclusive is computed. What is the result?
- Problem: A row of 5 seats is filled by 3 distinct people, leaving 2 seats empty. How many arrangements are possible if the empty seats…
- Problem: The sum of the squares of the odd numbers from 1 to 19 is what value?
- Problem: A grid of 3 rows and 3 columns is filled with the numbers 1 to 9 row by row. A "line" is a complete row, column or main diagonal…
- Problem: What is the number of lattice points (x, y) with x, y ≥ 0 and x + y ≤ 5?
- Problem: The array [5, 1, 4, 2, 3] is sorted by repeatedly swapping adjacent elements that are out of order (bubble sort). How many passes…