
Question 2
The current password is represented by the string currentPassword
, consisting only of lowercase Latin letters.
New password requirements have just been released. The new password, called newPassword
, must meet two specific requirements:
- It must be a palindrome.
- It must have a period of k. That is,
newPassword[i] = newPassword[i+k]
, for all1 ≤ i ≤ length(newPassword) - k
.
The objective is to determine the minimum number of characters that need to be changed in currentPassword
to create a newPassword
of the same length.
📌 Example
currentPassword = "abzbzb"
k = 3
Changing the first character of currentPassword
to 'z' creates a newPassword
of "zbzbzb"
, which is a palindrome with a period of 3.
Therefore, the answer is 1.
🛠️ Function Description
Complete the function findMinChanges
in the editor with the following parameters:
def findMinChanges(currentPassword: str, k: int) -> int:
Parameters:
string currentPassword
: the current passwordint k
: the required period of the new password
Returns:
int
: the minimum number of characters to change to make a validnewPassword
📎 Constraints:
1 ≤ k ≤ length(currentPassword) ≤ 2 * 10^5
currentPassword
only contains lowercase Latin letters.- It is guaranteed that
length(currentPassword)
is divisible byk
.
🔍 Sample Case 0
Input
currentPassword = "cbpebcbc"
k = 4
Output
2
Explanation
Changing the third and fourth characters to 'c' and 'b' respectively makes newPassword = "cbcbcbcb"
, which is a palindrome with period 4.
🔍 Sample Case 1
Input
currentPassword = "vsysvsv"
k = 3
Output
0

🧩 Question 3
There are n
developers, where the skill level of the i
th developer is given by i
, for 1 ≤ i ≤ n
.
The task is to form a team of developers for a hackathon.
A developer agrees to be on the team only if certain conditions are met. Given two arrays, lowerSkill
and higherSkill
, the i
th developer will join the team if:
- at most
lowerSkill[i]
team members have a lower skill level than them, and - at most
higherSkill[i]
team members have a higher skill level than them.
The objective is to select the largest possible team such that every developer on the team agrees with the team composition based on these conditions.
📌 Example
n = 5
lowerSkill = [1, 3, 2, 2, 2]
higherSkill = [2, 2, 1, 1, 3]
It is optimal to select developers with skill levels 1, 3, and 4:
- For developer with skill level 1:
There are two developers with higher skills,higherSkill[1] = 2
. - For developer with skill level 3:
One developer has a lower skill and one has a higher skill. - For developer with skill level 4:
Two developers with lower skills, one developer with higher skill.
Thus, all three developers are content.
Hence, the maximum number of developers is 3.
🛠️ Function Description
Complete the function getOptimalTeamSize
in the editor below:
def getOptimalTeamSize(lowerSkill: List[int], higherSkill: List[int]) -> int:
Parameters:
INTEGER_ARRAY lowerSkill
: required lower skill constraint for each developerINTEGER_ARRAY higherSkill
: required higher skill constraint for each developer
Returns:
INTEGER
: the maximum number of developers that can be selected

我们长期稳定承接各大科技公司如Citadel、TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Citadel, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
