Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the sum of the integers from 1 to 100 inclusive that are not perfect squares?
- A. 4666
- B. 4665
- C. 5050
- D. 385
Correct answer: B. 4665
The total of 1 to 100 is 5050, and the squares 1, 4, ..., 100 sum to 385. Subtracting gives 4665; the squares sum is the last option.
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
- Sum the largest power of two that divides each element of [12, 40, 7, 24]. What is the total?
- On a 3 by 3 grid, how many unordered pairs of distinct cells share a row or a column?
- What is the length of the longest run of equal consecutive values in [5, 5, 5, 6, 6, 5, 5, 5, 5]?
- How many length-2 substrings of "abbaabab" are either "ab" or "ba"?
- From task sizes [4, 5, 6, 3], what is the largest number of tasks you can keep so that their total size is at most 10?
- How many subsets (including the empty set, but counting each subset once) of [1, 2, 3, 4] have element sum equal to 5?