3101. Count Alternating Subarrays
You are given a binary array
nums
.We call a subarray alternating if no two adjacent elements in the subarray have the same value.
Return the number of alternating subarrays in
nums
.
3101. Count Alternating Subarrays
You are given a binary array
nums
.We call a subarray alternating if no two adjacent elements in the subarray have the same value.
Return the number of alternating subarrays in
nums
.
You are given two integers
numBottles
andnumExchange
.
numBottles
represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations:
- Drink any number of full water bottles turning them into empty bottles.
- Exchange
numExchange
empty bottles with one full water bottle. Then, increasenumExchange
by one.Note that you cannot exchange multiple batches of empty bottles for the same value of
numExchange
. For example, ifnumBottles == 3
andnumExchange == 1
, you cannot exchange3
empty water bottles for3
full bottles.Return the maximum number of water bottles you can drink.
An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer
x
. Return the sum of the digits ofx
ifx
is a Harshad number, otherwise, return-1
.
3098. Find the Sum of Subsequence Powers
You are given an integer array
nums
of lengthn
, and a positive integerk
.The power of a subsequence is defined as the minimum absolute difference between any two elements in the subsequence.
Return the sum of powers of all subsequences of
nums
which have length equal to\k
.Since the answer may be large, return it modulo
109 + 7
.
3097. Shortest Subarray With OR at Least K II
You are given an array
nums
of non-negative integers and an integerk
.An array is called special if the bitwise
OR
of all of its elements is at leastk
.Return the length of the shortest special non-empty subarray of
nums
, or return-1
if no special subarray exists.