[IBM] General Software Engineer HackerRank OA

1. Question 1

In a school, there are n students who want to participate in an academic decathlon. The teacher wants to select the maximum number of students possible. Each student has a certain skill level. For the team to be uniform, it is important that when the skill levels of its members are arranged in increasing order, the difference between any two consecutive skill levels is either 0 or 1. Find the maximum team size the teacher can form.

Example

skills = [10, 12, 13, 9, 14]

Valid teams, sorted, are {9, 10}, and {12, 13, 14}. These teams have team sizes 2 and 3 respectively, so the maximum team size is 3.

Function Description

Complete the function findMaxTeamSize in the editor below.

findMaxTeamSize has the following parameter:
int skills[n]: the skill levels of each student

Returns
int: the maximum possible size of the team

Constraints
1 ≤ n ≤ 10^5
1 ≤ skills[i] ≤ 10^9


2. Question 2

Given a list of names, determine the number of names in that list for which a given query string is a prefix. The prefix must be at least 1 character less than the entire name string.

Example
names = ['jackson', 'jacques', 'jack']
query = ['jack']

The complete query string 'jack' is a prefix of jackson but not of jacques or jack. The prefix cannot contain the entire name string, so 'jack' does not qualify.

Function Description

Complete the function findCompletePrefixes in the editor below. The function must return an array of integers that each denotes the number of names strings for which a query string is a prefix.

findCompletePrefixes has the following parameter(s):

  • string names[n]: an array of name strings
  • string query[q]: an array of query strings

Returns:

  • int[q]: each value[i] is the answer to query[i]

Constraints

  • 1 ≤ n ≤ 20000
  • 2 ≤ length of names[i], query[i] ≤ 30
  • 1 ≤ sum of the lengths of all names[i] ≤ 5 × 10^5
  • 1 ≤ q ≤ 200

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *