Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
How many integers n from 1 to 99 inclusive have both n and n + 1 squarefree (not divisible by any square greater than 1)?
- A. 34
- B. 61
- C. 33
- D. 90
Correct answer: C. 33
Check squarefreeness by testing divisibility by square factors d^2 up to sqrt(n). Pairs of consecutive numbers are tested directly over the range.
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
- Choose the fewest intervals of length 3 (covering integer points s, s+1, s+2 for a start s from 1 to 8) so that every integer point from 1…
- How many integers x with 1 ≤ x ≤ 2024 have NO two equal adjacent digits in their decimal representation?
- How many integers x with 1 ≤ x ≤ 500 have a decimal digit sum divisible by 3?
- You may swap the digits at exactly one pair of positions in the number 98368 (at most once). What is the largest number you can obtain?
- Children need greed factors [1, 2, 3, 5, 7]. Each child can receive at most one cookie, and a child is satisfied if the cookie size is at…
- In one move you may increase ALL but one element of the array [1, 2, 4, 7] by 1. What is the minimum number of moves to make all elements…