3022. Minimize OR of Remaining Elements Using Operations
You are given a 0-indexed integer array
numsand an integerk.In one operation, you can pick any index
iofnumssuch that0 <= i < nums.length - 1and replacenums[i]andnums[i + 1]with a single occurrence ofnums[i] & nums[i + 1], where&represents the bitwiseANDoperator.Return the minimum possible value of the bitwise
ORof the remaining elements ofnumsafter applying at mostkoperations.
3021. Alice and Bob Playing Flower Game
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are
xflowers in the clockwise direction between Alice and Bob, andyflowers in the anti-clockwise direction between them.The game proceeds as follows:
- Alice takes the first turn.
- In each turn, a player must choose either the clockwise or anti-clockwise direction and pick one flower from that side.
- At the end of the turn, if there are no flowers left at all, the current player captures their opponent and wins the game.
Given two integers,
nandm, the task is to compute the number of possible pairs(x, y)that satisfy the conditions:
- Alice must win the game according to the described rules.
- The number of flowers
xin the clockwise direction must be in the range[1,n].- The number of flowers
yin the anti-clockwise direction must be in the range[1,m].Return the number of possible pairs
(x, y)that satisfy the conditions mentioned in the statement.
3020. Find the Maximum Number of Elements in Subset
You are given an array of positive integers
nums.You need to select a subset of
numswhich satisfies the following condition:
- You can place the selected elements in a 0-indexed array such that it follows the pattern:
[x, x2, x4, ..., xk/2, xk, xk/2, ..., x4, x2, x](Note thatkcan be be any non-negative power of2). For example,[2, 4, 16, 4, 2]and[3, 9, 3]follow the pattern while[2, 4, 8, 4, 2]does not.Return the maximum number of elements in a subset that satisfies these conditions.
You are given a 0-indexed string
styped by a user. Changing a key is defined as using a key different from the last used key. For example,s = "ab"has a change of a key whiles = "bBBb"does not have any.Return the number of times the user had to change the key.
Note: Modifiers like
shiftorcaps lockwon’t be counted in changing the key that is if a user typed the letter'a'and then the letter'A'then it will not be considered as a changing of key.