Bulls and Cows | LeetCode | Google | Python

preview_player
Показать описание
Solving the popular bulls and cows problem on Leetcode asked in Google with time and space complexities explained.
Рекомендации по теме
Комментарии
Автор

Here the secret and guess strings are the same lengths, so n=m for the time and space complexities, now will be O(n), still linear.

SagarSharma-usru
Автор

Thank you so much for this great explanation. I am having troubles in understanding this line:
if num in count_secret:
if count_secret[num] > 0:
cows += 1
count_secret[num] -= 1
Could you please explain as to why we are having the second if condition? Thank you.

candymanful
join shbcf.ru