v1 time O(log(n)) space O(log(n))

if boundaries are involved, better to test with mind