In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how leetcode returns a subarray of K different integers. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Given a positive integer array A, if the number of different integers in a subarray of A happens to be K, the continuous and not necessarily independent subarray of An is called a good subarray.
(for example, there are three different integers in [1Pert 2, 3pr 1], and 3. )
Returns the number of good subarrays in A.
Example 1:
Output: a = [1, 2, 2, 1, 1, 2, 3], K = 2
Enter: 7
Explanation: a subarray that happens to be composed of two different integers: [1], [2], [1], [2], [2], [2], [2].
Example 2:
Input: a = [1, 2, 1, 3, 4], K = 3
Output: 3
Explanation: a subarray of exactly three different integers: [1], [2], [3], [3].
Tip:
one
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.