2022. Convert 1D Array Into 2D Array
You are given a 0-indexed 1-dimensional (1D) integer array
original
, and two integers,m
andn
. You are tasked with creating a 2-dimensional (2D) array withm
rows andn
columns using all the elements fromoriginal
.The elements from indices
0
ton - 1
(inclusive) oforiginal
should form the first row of the constructed 2D array, the elements from indicesn
to2 * n - 1
(inclusive) should form the second row of the constructed 2D array, and so on.Return an
m x n
2D array constructed according to the above procedure, or an empty 2D array if it is impossible.
3273. Minimum Amount of Damage Dealt to Bob
You are given an integer
power
and two integer arraysdamage
andhealth
, both having lengthn
.Bob has
n
enemies, where enemyi
will deal Bobdamage[i]
points of damage per second while they are alive (i.e.health[i] > 0
).Every second, after the enemies deal damage to Bob, he chooses one of the enemies that is still alive and deals
power
points of damage to them.Determine the minimum total amount of damage points that will be dealt to Bob before all
n
enemies are dead.
3272. Find the Count of Good Integers
You are given two positive integers
n
andk
.An integer
x
is called k-palindromic if:
x
is a palindrome.
x
is divisible byk
.An integer is called good if its digits can be rearranged to form a k-palindromic integer. For example, for
k = 2
, 2020 can be rearranged to form the k-palindromic integer 2002, whereas 1010 cannot be rearranged to form a k-palindromic integer.Return the count of good integers containing
n
digits.Note that any integer must not have leading zeros, neither before nor after rearrangement. For example, 1010 cannot be rearranged to form 101.
You are given a string
s
of lengthn
and an integerk
, wheren
is a multiple ofk
. Your task is to hash the strings
into a new string calledresult
, which has a length ofn / k
.First, divide
s
inton / k
substrings, each with a length ofk
. Then, initializeresult
as an empty string.For each substring in order from the beginning:
- The hash value of a character is the index of that character in the English alphabet (e.g.,
'a' → 0
,'b' → 1
, …,'z' → 25
).- Calculate the sum of all the hash values of the characters in the substring.
- Find the remainder of this sum when divided by 26, which is called
hashedChar
.- Identify the character in the English lowercase alphabet that corresponds to
hashedChar
.- Append that character to the end of
result
.
3270. Find the Key of the Numbers
You are given three positive integers
num1
,num2
, andnum3
.The
key
ofnum1
,num2
, andnum3
is defined as a four-digit number such that:
- Initially, if any number has less than four digits, it is padded with leading zeros.
- The
ith
digit (1 <= i <= 4
) of thekey
is generated by taking the smallest digit among theith
digits ofnum1
,num2
, andnum3
.Return the
key
of the three numbers without leading zeros (if any).
3263. Convert Doubly Linked List to Array I
You are given the
head
of a doubly linked list, which contains nodes that have a next pointer and a previous pointer.Return an integer array which contains the elements of the linked list in order.
3269. Constructing Two Increasing Arrays
Given 2 integer arrays
nums1
andnums2``nums1
andnums2
, after doing the following.Replace every 0 with an even positive integer and every 1 with an odd positive integer. After replacement, both arrays should be increasing and each integer should be used at most once.
Return the minimum possible largest number after applying the changes.