Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many elements of [12, 19, 40, 7, 31, 22, 13, 8] have a decimal digit sum divisible by 4?
- A. 6
- B. 5
- C. 3
- D. 1
Correct answer: B. 5
Compute the digit sum of each value (for example 19 gives 10 and 31 gives 4) and test divisibility by 4. Testing the number itself modulo 4 is a different property.
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 perfect squares lie in the range [50, 250] inclusive?
- How many contiguous subarrays of [6, 10, 15, 4] have gcd exactly 1?
- A linked list holds 1..8 in order. Reverse the first group of 2 nodes, keep the next group of 2 as is, reverse the next, and so on. What…
- Exactly how many permutations of 1..5 can be sorted by a single stack (push and pop operations, output must be 1, 2, 3, 4, 5)?
- A queue holds 3, 1, 4, 2, 5 from front to back. You repeatedly look at the front element: if it is the next value needed (starting with…
- For windows of size 3 over [3, 1, 4, 2, 5, 1, 6, 0], how many windows have their maximum at the last position of the window (ties count as…