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
numBottlesandnumExchange.
numBottlesrepresents 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
numExchangeempty bottles with one full water bottle. Then, increasenumExchangeby one.Note that you cannot exchange multiple batches of empty bottles for the same value of
numExchange. For example, ifnumBottles == 3andnumExchange == 1, you cannot exchange3empty water bottles for3full 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 ofxifxis a Harshad number, otherwise, return-1.
3098. Find the Sum of Subsequence Powers
You are given an integer array
numsof 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
numswhich 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
numsof non-negative integers and an integerk.An array is called special if the bitwise
ORof all of its elements is at leastk.Return the length of the shortest special non-empty subarray of
nums, or return-1if no special subarray exists.