← Quiz: Approaching DSA Interview Problems: all 10 questions
Quiz: Approaching DSA Interview Problems · Question 5 of 10
What does this print? (code)
What does this print?
marks = [50, 70, 70, 90]
cnt = [0] * 101
for m in marks:
cnt[m] += 1
P = [0] * 102
for i in range(101):
P[i + 1] = P[i] + cnt[i]
print(P[71] - P[60], P[101] - P[0])
- A.1 4
- B.2 4
- C.3 4
- D.2 3
Answer & explanation
Correct answer: 2 4
P[71] − P[60] counts marks 60..70: the two 70s. P[101] − P[0] counts everyone.
Can you get the rest right without peeking?
Take the timed Quiz: Approaching DSA Interview Problems quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →