In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how leetcode calculates the length of the longest sub-array whose product is a positive number, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.
Give you an integer array nums, please find out the length of the longest subarray whose product is positive.
A subarray of an array is an array of zero or more consecutive numbers in the original array.
Please return the length of the longest subarray whose product is positive.
Example 1:
Input: nums = [1mai mai 2mi mi 3jue 4]
Output: 4
Explanation: the product of the array itself is a positive number with a value of 24.
Example 2:
Input: nums = [0je 1m m m 2m m 3m m el 4]
Output: 3
Explanation: the subarray whose longest product is positive is [1], and the product is 6.
Note that we cannot include 0 in the subarray, because the product is 0, not a positive number.
Example 3:
Input: nums = [- 1 flint 2meme 3jin0jue 1]
Output: 2
Explanation: the longest subarray whose product is positive is [- 1] or [- 2].
Example 4:
Input: nums = [- 1BI 2]
Output: 1
Example 5:
Input: nums = [1, 2, 3, 5, 5, 6, 4, 0, 10]
Output: 4
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.