Data Structures & AlgorithmsModerateTCS NQT · Product Company OA
Problem: What is the smallest integer x >= 100 divisible by 13? Run the code.
Problem: What is the smallest integer x >= 100 divisible by 13? Run the code.
print(next(x for x in range(100, 200) if x % 13 == 0))What is printed?
- A. 104
- B. 100
- C. 117
- D. 130
Correct answer: A. 104
100 = 13 × 7 + 9, so 100 itself fails the test and the first multiple at or above 100 is 13 × 8 = 104. Jumping to 13 × 9 = 117 skips that first valid multiple.
More Coding Interview Problems questions
- Problem: How many distinct non-empty prefixes does the string 'banana' have? Run the code. python s = 'banana' print(len({s[:i] for i in…
- Problem: How many integers in [1, 30] are even but not divisible by 4? Run the code. python print(sum(1 for x in range(1, 31) if x % 2 ==…
- Problem: What is the total length covered by the union of the intervals [1, 3], [2, 6] and [8, 10]? Run the code. python iv = sorted([(1…
- Problem: What does this Python snippet print? def add(x, bucket=[]): bucket.append(x) return len(bucket) add(1); add(2) print(add(3))
- Problem: What does this Python snippet print? g = [[0]3]3 g[1][2] = 7 print(sum(map(sum, g)))
- Problem: What does this Python snippet print? print(-7 // 2, -7 % 3, 7 // -2)