herrDeng網內搜尋

自訂搜尋

Ads

2024年3月29日 星期五

C++. Python Sliding window與組合公式解Leetcode 2962


python, CPP Sliding window與組合公式解Leetcode 2962. Count Subarrays Where Max Element Appears at Least K Times

 兩種截然不同的方式解題,一種是用組合公式,算左右端點的可能,乘法律、加法律,數學解法先解出。
另一種是sliding window就用這幾天解題的那種pattern一套就靈,快速簡潔。
------
There are two completely different ways to solve the problem. One is to use combination formulas to calculate the number of possiblities for left right ends using multiplicative principle and additive principle. The mathematical solution is solved first.
The other is the sliding window, which uses the same pattern that has been used to solve problems these days. It is quick and concise.


沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章