mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个整数数组 <code>arr</code> 。请你返回和为 <strong>奇数</strong> 的子数组数目。</p>
 | 
						||
 | 
						||
<p>由于答案可能会很大,请你将结果对 <code>10^9 + 7</code> 取余后返回。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>arr = [1,3,5]
 | 
						||
<strong>输出:</strong>4
 | 
						||
<strong>解释:</strong>所有的子数组为 [[1],[1,3],[1,3,5],[3],[3,5],[5]] 。
 | 
						||
所有子数组的和为 [1,4,9,3,8,5].
 | 
						||
奇数和包括 [1,9,3,5] ,所以答案为 4 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2 :</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>arr = [2,4,6]
 | 
						||
<strong>输出:</strong>0
 | 
						||
<strong>解释:</strong>所有子数组为 [[2],[2,4],[2,4,6],[4],[4,6],[6]] 。
 | 
						||
所有子数组和为 [2,6,12,4,10,6] 。
 | 
						||
所有子数组和都是偶数,所以答案为 0 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>arr = [1,2,3,4,5,6,7]
 | 
						||
<strong>输出:</strong>16
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 4:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>arr = [100,100,99,99]
 | 
						||
<strong>输出:</strong>4
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 5:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>arr = [7]
 | 
						||
<strong>输出:</strong>1
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= arr.length <= 10^5</code></li>
 | 
						||
	<li><code>1 <= arr[i] <= 100</code></li>
 | 
						||
</ul>
 |