This problem is a classic binary search application. Well there’s a template that is supposed to be used with problems solved with binary search - you can find it here Binary Search
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is since we are visiting all elements in the array only once.
-
Memory The memory usage is since we use the
collections.defaultdict
object to store multiple and modulos.
— A