The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers
x
andy
, return the Hamming distance between them.
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers
x
andy
, return the Hamming distance between them.
3154. Find Number of Ways to Reach the K-th Stair
You are given a non-negative integer
k
. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0.Alice has an integer
jump
, with an initial value of 0. She starts on stair 1 and wants to reach stairk
using any number of operations. If she is on stairi
, in one operation she can:
- Go down to stair
i - 1
. This operation cannot be used consecutively or on stair 0.- Go up to stair
i + 2jump
. And then,jump
becomesjump + 1
.Return the total number of ways Alice can reach stair
k
.Note that it is possible that Alice reaches the stair
k
, and performs some operations to reach the stairk
again.
3153. Sum of Digit Differences of All Pairs
You are given an array
nums
consisting of positive integers where all integers have the same number of digits.The digit difference between two integers is the count of different digits that are in the same position in the two integers.
Return the sum of the digit differences between all pairs of integers in
nums
.
An array is considered special if every pair of its adjacent elements contains two numbers with different parity.
You are given an array of integer
nums
and a 2D integer matrixqueries
, where forqueries[i] = [fromi, toi]
your task is to check that subarraynums[fromi..toi]
is special or not.Return an array of booleans
answer
such thatanswer[i]
istrue
ifnums[fromi..toi]
is special.
An array is considered special if every pair of its adjacent elements contains two numbers with different parity.
You are given an array of integers
nums
. Returntrue
ifnums
is a special array, otherwise, returnfalse
.
1742. Maximum Number of Balls in a Box
You are working in a ball factory where you have
n
balls numbered fromlowLimit
up tohighLimit
inclusive (i.e.,n == highLimit - lowLimit + 1
), and an infinite number of boxes numbered from1
toinfinity
.Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball’s number. For example, the ball number
321
will be put in the box number3 + 2 + 1 = 6
and the ball number10
will be put in the box number1 + 0 = 1
.Given two integers
lowLimit
andhighLimit
, return the number of balls in the box with the most balls.
Given an integer array
arr
, returntrue
if there are three consecutive odd numbers in the array. Otherwise, returnfalse
.
2423. Remove Letter To Equalize Frequency
You are given a 0-indexed string
word
, consisting of lowercase English letters. You need to select one index and remove the letter at that index fromword
so that the frequency of every letter present inword
is equal.Return
true
if it is possible to remove one letter so that the frequency of all letters inword
are equal, andfalse
otherwise.Note:
- The frequency of a letter
x
is the number of times it occurs in the string.- You must remove exactly one letter and cannot choose to do nothing.
3151. Maximum Number of Upgradable Servers
You have
n
data centers and need to upgrade their servers.You are given four arrays
count
,upgrade
,sell
, andmoney
of lengthn
, which show:
- The number of servers
- The cost of upgrading a single server
- The money you get by selling a server
- The money you initially have
for each data center respectively.
Return an array
answer
, where for each data center, the corresponding element inanswer
represents the maximum number of servers that can be upgraded.Note that the money from one data center cannot be used for another data center.
1708. Largest Subarray Length K
An array
A
is larger than some arrayB
if for the first indexi
whereA[i] != B[i]
,A[i] > B[i]
.For example, consider
0
-indexing:
[1,3,2,4] > [1,2,2,4]
, since at index1
,3 > 2
.[1,4,4,4] < [2,1,1,1]
, since at index0
,1 < 2
.A subarray is a contiguous subsequence of the array.
Given an integer array
nums
of distinct integers, return the largest subarray ofnums
of lengthk
.