Uncategorized · 7 2 月, 2024 0

Citadel OA 最新真题 02/07/24

最近Citadel OA出了新题,一起来看看吧。

Lottery Winner

HackerRankNews distributed lottery tickets to everyone, with the winning lottery ID denoted by winnerID.

To win the lottery, a customer with a lottery ID represented by lotteryID aims to maximize the length of the longest common subsequence between the strings lotteryID and winnerID. To achieve this, the customer can perform up to k operations. Each operation allows the customer to change any character in lotteryID to its next or previous character.

The goal is to determine the maximum possible length of the longest common subsequence after performing at most k such operations.

Note:

  • Operations can only be performed on lotteryID, not on winnerID.
  • The next character of a given character ch is the character that comes just after it in the alphabet. Similarly, the previous character is the character that comes just before it in the alphabet. For example, the next character of ‘m’ is ‘n’, and the previous character is ‘l’. For ‘z’, the next character is ‘a’, and for ‘a’, the previous character is ‘z’.

Example:

Consider lotteryID = “fpelqanxyk”, winnerID = “hackerrank”, and maximum allowed operations k = 6. One optimal way to perform the operations is as follows:

  1. Select i = 0, convert lotteryID[0] to its next character, resulting in “gpelqanxyk”.
  2. Select i = 0, convert lotteryID[0] to its next character, resulting in “hpelqanxyk”.
  3. Select i = 2, convert lotteryID[2] to its previous character, resulting in “hpdlqanxyk”.
  4. Select i = 2, convert lotteryID[2] to its previous character, resulting in “hpclqanxyk”.
  5. Select i = 3, convert lotteryID[3] to its previous character, resulting in “hpckqanxyk”.
  6. Select i = 4, convert lotteryID[4] to its next character, resulting in “hpckranxyk”.

Now, the longest common subsequence between lotteryID and winnerID is “hckranxyk”. The length of the longest common subsequence is 7, which is the maximum possible. Therefore, the answer is 7.

Function Description:

Complete the function getMaximumLength below. getMaximumLength has the following parameters:

  • string lotteryID: the lottery ID of the customer
  • string winnerID: the winner’s ID published in the newspaper
  • int k: the maximum number of operations

Returns:

  • int: the length of the longest common subsequence

Constraints:

  • 1 ≤ length(lotteryID), length(winnerID) ≤ 100
  • 0 ≤ k ≤ 200

Hacker’s Team

A cyber security firm is building a team of hackers to take down a network of cybercriminals.The skill level of the ith hacker of team A is team_a[i] and of team B is team_b[i]. A team is considered strong if for each index /a hacker is selected either from team A or team B, and the skill levels of the selected team are non-decresasing.

Given two arrays team_a and team_b of n integers each,.choose two indices i and j such that subarrays[team_a[i],team_a[i+1]……team_a[j]] and [team_b[i],team_b[i+1]…team_b[j]] can form a strong team.Find the maximum possible value if (j-i+1)i.e.the length of the chosen subarray

Example:
Given, n=4, team_a={5, 2, 4, 1}and team_b ={3, 6, 2, 2}

Hence 3 is the answer.

Function Description:

Complete the function getMaxSubarrayLen in the editor below:

getMaxSubarrayten has the following parameters:

  • int team a[n]: skill levels of team A
  • int team b[n]: skill levels of team B

Returns:
int: the maximum subarray length that can be chosen to form a strong team

Constraints:

  • 1 ≤ n ≤ 10^5
  • 1 ≤ team_a[i], team_b[i] ≤ 10^9

我们还提供OA与VO的咨询与支持服务,如果有需要,请联系我们:

chen@csoahelp.com

We also provide consultation and support services for OA and VO. If needed, please feel free to contact us:

chen@csoahelp.com