Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
How many integers from 1 to 200 inclusive have exactly 3 positive divisors?
- A. 7
- B. 46
- C. 6
- D. 14
Correct answer: C. 6
Numbers with exactly three divisors are squares of primes. Counting primes p with p squared at most 200 gives the answer, since 14 squared exceeds 200 but 13 squared does not.
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 contiguous subarrays of [3, 1, 2, 5, 4, 6] consist of distinct consecutive integers (in any order)?
- What is the length of the shortest contiguous subarray of [1, 2, 3, 1, 2, 4, 3] that contains every distinct value present in the array?
- How many integers from 1 to 200 inclusive are palindromes when written in decimal?
- How many index pairs i < j in [3, 5, 6, 9, 10] have a[i] XOR a[j] with an odd number of 1-bits?
- What is the minimum number of swaps of any two positions needed to make [2, 1, 2, 1, 3, 3, 1] sorted in non-decreasing order?
- Concatenate "abba" and "baab" into one string, then count its distinct substrings of length 2.