[LeetCode] Count Alternating Subarrays

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.

Read more
[LeetCode] Water Bottles II

3100. Water Bottles II

You are given two integers numBottles and numExchange.

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, increase numExchange by one.

Note that you cannot exchange multiple batches of empty bottles for the same value of numExchange. For example, if numBottles == 3 and numExchange == 1, you cannot exchange 3 empty water bottles for 3 full bottles.

Return the maximum number of water bottles you can drink.

Read more
[LeetCode] Harshad Number

3099. Harshad Number

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 of x if x is a Harshad number, otherwise, return -1.

Read more
[AtCoder] C - Catastrophic RouletteRead more
[AtCoder] F - Earn to AdvanceRead more
[AtCoder] E - 7x7x7Read more
[AtCoder] F - BreakdownRead more
[AtCoder] F - Product EqualityRead more
[LeetCode] Find the Sum of Subsequence Powers

3098. Find the Sum of Subsequence Powers

You are given an integer array nums of length n, and a positive integer k.

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.

Read more
[LeetCode] Shortest Subarray With OR at Least K II

3097. Shortest Subarray With OR at Least K II

You are given an array nums of non-negative integers and an integer k.

An array is called special if the bitwise OR of all of its elements is at least k.

Return the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.

Read more