[Demonware] 2025 coop Hackerrank OA

Counting Triplets

There is an integer array arr[n] and an integer value d. The array is indexed from 1 to n.

Count the number of distinct triplets (i, j, k) such that 0 < i < j < k ≤ n and the sum (a[i] + a[j] + a[k]) is divisible by d.

Example

a = [3, 3, 4, 7, 8]
d = 5

The following triplets are divisible by d = 5. Following are the triplets whose sum is divisible by d (1-based indexing):

  • Indices (1, 2, 3), sum = 3 + 3 + 4 = 10
  • Indices (1, 3, 5), sum = 3 + 4 + 8 = 15
  • Indices (2, 3, 4), sum = 3 + 4 + 8 = 15

Since there is no other triplet divisible by d = 5, return 3.

Function Description

Complete the function getTripletCount in the editor below.

getTripletCount has the following parameters:

  • int a[n]: an array of integers
  • int d: an integer

Returns

  • int: the number of distinct triplets

Constraints

  • 3 ≤ n ≤ 10³
  • 1 ≤ a[i] ≤ 10⁹
  • 2 ≤ d ≤ 10⁶

SQL: Freelance Platform Candidate Review

A company's HR department needs an SQL query against data from a freelance hiring platform.

The result should have the following columns: first_name | last_name | email | job_success_score.

It should be sorted in descending order by job_success_score, then in ascending order by first_name and last_name.

Limit the result to the first ten records.

Note:

  • Only profiles that have a "JSS" (Job Success Score) greater than 90 should be included.
  • Only those profiles that have passed the verification process (is_verified is 1) should be included.

Schema

profiles

nametypedescription
idSMALLINTunique id, primary key
first_nameVARCHAR(255)
last_nameVARCHAR(255)
emailVARCHAR(255)
is_verifiedSMALLINT1 = True, 0 = False

stats

nametypedescription
profile_idSMALLINTforeign key into profiles.id
job_success_scoreSMALLINT

Counting Arrays

There is an array of n non-negative integers, arr. In one operation, some positive integer x is chosen and 1 is subtracted from all the numbers of the array which are greater than or equal to x. Find the number of different final arrays possible after the operation is applied 0 or more times. Return the answer modulo (10⁹ + 7).

Note:

  • 1-based indexing is used.
  • Different values of x can be chosen for different operations.
  • Two final arrays a and b are considered different if there is at least one i (1 ≤ i ≤ n) such that a[i] ≠ b[i].

Example

Consider n = 2, arr = [1, 2].

There are four different final arrays possible.

  • x = 0 operations yields [1, 2].
  • x = 1 yields [0, 1].
  • x = 2 yields [1, 1].
  • x = 2 and then x = 1 yields [0, 0].

Notice that choosing x = 1 and then x = 1 will give [0, 0] which has been counted already. So, the number of different final arrays achievable is 4. Return 4 modulo (10⁹ + 7) which equals 4.

Function Description

Complete the function getCount in the editor below.

getCount has the following parameters:

  • int arr[n]: the original array

Returns

  • int: the number of different final arrays achievable, modulo (10⁹ + 7).

我们长期稳定承接各大科技公司如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 *