Leetcode 2348: Number of Zero-Filled Subarrays

preview_player
Показать описание

Difficulty: Medium

#leetcode #python

📚 MY ALGORITHMS BOOKS RECOMMENDATIONS:

📚 MY SYSTEM DESIGN BOOKS RECOMMENDATIONS:

🎥 MY FAVOURITE GEAR
Рекомендации по теме
Комментарии
Автор

[1, 2, 3] # Nonempty (not necessarily contiguous) subarrays are 2**3-1 or 2**n-1. In your example, you had [1, 3] (not contiguous) instead of [2, 3] which will take the count to 7.

What you are writing is true for all elements being the same but distinct by position. n+(n-1)+....+1=n(n+1)/2.

Sorry about the comment since I was new to the definition of subarrays, : )

atithi
welcome to shbcf.ru