Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: An 8-bit unsigned counter starts at 250 and is incremented by 7 each step, wrapping modulo 256. How many increments until the counter first becomes less than 100 (counting the increment that makes it less than 100)?
- A. 2
- B. 0
- C. 1
- D. 3
Correct answer: C. 1
Simulate with wrap-around modulo 256 and stop when the value first drops below 100. Treating the counter as unbounded never triggers the wrap that matters here.
More Coding Interview Problems questions
- Problem: The Pascal triangle rows are numbered from row 0 (single 1). What is the sum of all entries in row 12 that are odd?
- Problem: Count the strings of length 4 over the alphabet {a, b, c} that contain no two adjacent equal characters and do not contain the…
- Problem: The number of inversions in a permutation of 1..8 given as [4, 7, 1, 8, 2, 6, 3, 5] is what value?
- Problem: On a tree with 9 nodes labelled 1–9, edges 1-2, 1-3, 2-4, 2-5, 3-6, 6-7, 6-8, 8-9, count the unordered pairs of nodes whose path…
- Problem: A string is a palindrome-partition target: what is the minimum number of cuts needed to split "abbacxcaxyyx" into palindromic…
- Problem: A word-ladder graph: vertices are words of length 3 from {cat, cot, cog, dot, dog, hat, hot} and two words are adjacent when they…