0

What will be the O(1) solution for accepting only those numbers from array which are divisible by 'a' and 'b' but not by both?

'a','b' and array should be taken from user as input.

4th Feb 2019, 5:02 PM
Aryan 🇼🇳
1 Answer
+ 3
I don't think there is an O(1) solution, you have to iterate over the entire array once in order to know what is in it in the first place which makes it an O(n) solution.
4th Feb 2019, 5:58 PM
Dennis
Dennis - avatar