You are given an integer array
rewardValues
of lengthn
, representing the values of rewards.Initially, your total reward
x
is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
 Choose an unmarked index
i
from the range[0, n  1]
. If
rewardValues[i]
is greater than your current total rewardx
, then addrewardValues[i]
tox
(i.e.,x = x + rewardValues[i]
), and mark the indexi
.Return an integer denoting the maximum total reward you can collect by performing the operations optimally.
1 

You are given an integer array
rewardValues
of lengthn
, representing the values of rewards.Initially, your total reward
x
is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
 Choose an unmarked index
i
from the range[0, n  1]
. If
rewardValues[i]
is greater than your current total rewardx
, then addrewardValues[i]
tox
(i.e.,x = x + rewardValues[i]
), and mark the indexi
.Return an integer denoting the maximum total reward you can collect by performing the operations optimally.
1 

You are given two integers
n
andk
.Initially, you start with an array
a
ofn
integers wherea[i] = 1
for all0 <= i <= n  1
. After each second, you simultaneously update each element to be the sum of all its preceding elements plus the element itself. For example, after one second,a[0]
remains the same,a[1]
becomesa[0] + a[1]
,a[2]
becomesa[0] + a[1] + a[2]
, and so on.Return the value of
a[n  1]
afterk
seconds.Since the answer may be very large, return it modulo
109 + 7
.
1 

You are given two positive integers
n
andk
. There aren
children numbered from0
ton  1
standing in a queue in order from left to right.Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches either end of the line, i.e. child 0 or child
n  1
, the direction of passing is reversed.Return the number of the child who receives the ball after
k
seconds.
1  class Solution { 
You are given an integer array
nums
and a nonnegative integerk
. A sequence of integersseq
is called good if there are at mostk
indicesi
in the range[0, seq.length  2]
such thatseq[i] != seq[i + 1]
.Return the maximum possible length of a good subsequence of
nums
.
1 

You are given an integer array
nums
and a nonnegative integerk
. A sequence of integersseq
is called good if there are at mostk
indicesi
in the range[0, seq.length  2]
such thatseq[i] != seq[i + 1]
.Return the maximum possible length of a good subsequence of
nums
.
1 

A competition consists of
n
players numbered from0
ton  1
.You are given an integer array
skills
of sizen
and a positive integerk
, whereskills[i]
is the skill level of playeri
. All integers inskills
are unique.All players are standing in a queue in order from player
0
to playern  1
.The competition process is as follows:
 The first two players in the queue play a game, and the player with the higher skill level wins.
 After the game, the winner stays at the beginning of the queue, and the loser goes to the end of it.
The winner of the competition is the first player who wins
k
games in a row.Return the initial index of the winning player.
1  class Solution { 
You are given a string
s
.Your task is to remove all digits by doing this operation repeatedly:
 Delete the first digit and the closest nondigit character to its left.
Return the resulting string after removing all digits.
1  class Solution { 
Given a string array
words
, return an array of all characters that show up in all strings within thewords
(including duplicates). You may return the answer in any order.
1  class Solution { 
You are given an array
nums
and an integerk
. You need to find a subarray ofnums
such that the absolute difference betweenk
and the bitwiseAND
of the subarray elements is as small as possible. In other words, select a subarraynums[l..r]
such thatk  (nums[l] AND nums[l + 1] ... AND nums[r])
is minimum.Return the minimum possible value of the absolute difference.
A subarray is a contiguous nonempty sequence of elements within an array.
1  class Solution { 
1 

You are given a string
s
. It may contain any number of'*'
characters. Your task is to remove all'*'
characters.While there is a
'*'
, do the following operation:
 Delete the leftmost
'*'
and the smallest non'*'
character to its left. If there are several smallest characters, you can delete any of them.Return the lexicographically smallest resulting string after removing all
'*'
characters.
1  class Solution { 
You are given a positive integer
days
representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D arraymeetings
of sizen
where,meetings[i] = [start_i, end_i]
represents the starting and ending days of meetingi
(inclusive).Return the count of days when the employee is available for work but no meetings are scheduled.
Note: The meetings may overlap.
1  class Solution { 
You are given a string
s
. Simulate events at each secondi
:
 If
s[i] == 'E'
, a person enters the waiting room and takes one of the chairs in it. If
s[i] == 'L'
, a person leaves the waiting room, freeing up a chair.Return the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.
1  class Solution { 
You are given an array
nums
consisting of integers. You are also given a 2D arrayqueries
, wherequeries[i] = [posi, xi]
.For query
i
, we first setnums[posi]
equal toxi
, then we calculate the answer to queryi
which is the maximum sum of a subsequence ofnums
where no two adjacent elements are selected.Return the sum of the answers to all queries.
Since the final answer may be very large, return it modulo
109 + 7
.A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
1 

You are given 2 integer arrays
nums1
andnums2
of lengthsn
andm
respectively. You are also given a positive integerk
.A pair
(i, j)
is called good ifnums1[i]
is divisible bynums2[j] * k
(0 <= i <= n  1
,0 <= j <= m  1
).Return the total number of good pairs.
1 

Given a string
word
, compress it using the following algorithm:
 Begin with an empty string
comp
. Whileword
is not empty, use the following operation:
 Remove a maximum length prefix of
word
made of a single characterc
repeating at most 9 times. Append the length of the prefix followed by
c
tocomp
.Return the string
comp
.
1 

You are given 2 integer arrays
nums1
andnums2
of lengthsn
andm
respectively. You are also given a positive integerk
.A pair
(i, j)
is called good ifnums1[i]
is divisible bynums2[j] * k
(0 <= i <= n  1
,0 <= j <= m  1
).Return the total number of good pairs.
1 

There exists an infinite number line, with its origin at 0 and extending towards the positive xaxis.
You are given a 2D array
queries
, which contains two types of queries:
 For a query of type 1,
queries[i] = [1, x]
. Build an obstacle at distancex
from the origin. It is guaranteed that there is no obstacle at distancex
when the query is asked. For a query of type 2,
queries[i] = [2, x, sz]
. Check if it is possible to place a block of sizesz
anywhere in the range[0, x]
on the line, such that the block entirely lies in the range[0, x]
. A block cannot be placed if it intersects with any obstacle, but it may touch it. Note that you do not actually place the block. Queries are separate.Return a boolean array
results
, whereresults[i]
istrue
if you can place the block specified in theith
query of type 2, andfalse
otherwise.
1 

You are given an integer
limit
and a 2D arrayqueries
of sizen x 2
.There are
limit + 1
balls with distinct labels in the range[0, limit]
. Initially, all balls are uncolored. For every query inqueries
that is of the form[x, y]
, you mark ballx
with the colory
. After each query, you need to find the number of distinct colors among the balls.Return an array
result
of lengthn
, whereresult[i]
denotes the number of distinct colors afterith
query.Note that when answering a query, lack of a color will not be considered as a color.
1  class Solution { 
You are given an integer array
nums
, an integer arrayqueries
, and an integerx
.For each
queries[i]
, you need to find the index of thequeries[i]th
occurrence ofx
in thenums
array. If there are fewer thanqueries[i]
occurrences ofx
, the answer should be 1 for that query.Return an integer array
answer
containing the answers to all queries.
1  class Solution { 
You are given an array
nums
, where each number in the array appears either once or twice.Return the bitwise
XOR
of all the numbers that appear twice in the array, or 0 if no number appears twice.
1  class Solution { 
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.
1  class Solution { 
You are given a nonnegative 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.
1 

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
.
1 

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.
1  class Solution { 
1 
