1118. Number of Days in a Month
Given a year
yearand a monthmonth, return the number of days of that month.
1118. Number of Days in a Month
Given a year
yearand a monthmonth, return the number of days of that month.
Given an array of strings
wordsDictand two different strings that already exist in the arrayword1andword2, return the shortest distance between these two words in the list.
1085. Sum of Digits in the Minimum Number
Given an integer array
nums, return0if the sum of the digits of the minimum integer innumsis odd, or1otherwise.
A dieter consumes
calories[i]calories on thei-th day.Given an integer
k``kdays (calories[i], calories[i+1], ..., calories[i+k-1]for all0 <= i <= n-k``kdays (calories[i] + calories[i+1] + ... + calories[i+k-1]):
- If
T < lower, they performed poorly on their diet and lose 1 point;- If
T > upper, they performed well on their diet and gain 1 point;- Otherwise, they performed normally and there is no change in points.
Initially, the dieter has zero points. Return the total number of points the dieter has after dieting for
calories.lengthdays.Note that the total points can be negative.
1196. How Many Apples Can You Put into the Basket
You have some apples and a basket that can carry up to
5000units of weight.Given an integer array
weightwhereweight[i]is the weight of theithapple, return the maximum number of apples you can put in the basket.
Given an initial array
arr, every day you produce a new array using the array of the previous day.On the
i-th day, you do the following operations on the array of dayi-1to produce the array of dayi:
- If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented.
- If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented.
- The first and last elements never change.
After some days, the array does not change. Return that final array.
A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit
'0'with the letter'O', and the digit'1'with the letter'I'. Such a representation is valid if and only if it consists only of the letters in the set{'A', 'B', 'C', 'D', 'E', 'F', 'I', 'O'}.Given a string
numrepresenting a decimal integern, return the Hexspeak representation ofnif it is valid, otherwise return"ERROR".
1933. Check if String Is Decomposable Into Value-Equal Substrings
A value-equal string is a string where all characters are the same.
- For example,
"1111"and"33"are value-equal strings.- In contrast,
"123"is not a value-equal string.Given a digit string
s``2``3.Return
trueif you can decomposesaccording to the above rules. Otherwise, returnfalse.A substring is a contiguous sequence of characters in a string.
2229. Check if an Array Is Consecutive
Given an integer array
nums, returntrueifnumsis consecutive, otherwise returnfalse.An array is consecutive if it contains every number in the range
[x, x + n - 1](inclusive), wherexis the minimum number in the array andnis the length of the array.
2689. Extract Kth Character From The Rope Tree
You are given the
rootof a binary tree and an integerk. Besides the left and right children, every node of this tree has two other properties, a stringnode.valcontaining only lowercase English letters (possibly empty) and a non-negative integernode.len. There are two types of nodes in this tree:
- Leaf: These nodes have no children,
node.len = 0, andnode.valis some non-empty string.- Internal: These nodes have at least one child (also at most two children),
node.len > 0, andnode.valis an empty string.The tree described above is called a Rope binary tree. Now we define
S[node]recursively as follows:
- If
nodeis some leaf node,S[node] = node.val,- Otherwise if
nodeis some internal node,S[node] = concat(S[node.left], S[node.right])andS[node].length = node.len.Return k-th character of the string
S[root].Note: If
sandpare two strings,concat(s, p)is a string obtained by concatenatingptos. For example,concat("ab", "zz") = "abzz".