Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the largest n such that 1 + 2 + ... + n does not exceed 1000?
- A. 45
- B. 44
- C. 46
- D. 48
Correct answer: B. 44
44 * 45 / 2 = 990 is within the limit, but 45 * 46 / 2 = 1035 exceeds it.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many primes p with 2 <= p <= 30 satisfy p ≡ 1 (mod 4)?
- How many integers x in [1, 100] satisfy x ≡ 3 (mod 4) and x ≡ 7 (mod 10)?
- What is 2^100 mod 9?
- A 12-hour clock shows 1:30 p.m. Ignoring seconds, what hour (1 to 12) is shown 500 minutes later?
- Starting at x = 1, repeatedly apply x -> 3x mod 11. How many steps are needed to return to 1?
- Starting from n = 100, repeat: if n is divisible by 3, divide it by 3; otherwise subtract 1. How many steps are needed to reach 1?