Leetcode - Get Maximum in Generated Array (Python)

preview_player
Показать описание
January 2021 Leetcode Challenge
Leetcode - Get Maximum in Generated Array #1646
Рекомендации по теме
Комментарии
Автор

nice dude! the divide by two thing didn't even occur to me. i just built the array up to n//2 and updated a max to return at the end.

if n == 0:
return 0
if n == 1:
return 1

array = [0]*(n+1)
array[1] = 1
max_val = 1
for i in range(1, len(array)//2):
array[2*i] = array[i]
array[(2*i)+1] = array[i] + array[i+1]
max_val = max(max_val, array[(2*i)+1])

return max_val

janmichaelaustria
Автор

Sir if you have time can you make videos on concepts of Trees

consistentthoughts
visit shbcf.ru