[Fortinet] Backend Developer (FortiNDR)
  1. C: Sort it Wisely

Sort an array of student records by score in descending order. Break ties by the students' first names and then by last names in ascending alphabetical order for both.

Function Description

Complete the function sort_students in the editor below.

sort_students has the following parameters:

  • int n: the number of students.
  • struct Student students[]: an array of students (see the stub header for a definition of struct).

Constraints

  • 1 ≤ n ≤ 500
  • 1 ≤ score ≤ 100
  • 1 ≤ |first_name| ≤ 50
  • 1 ≤ |last_name| ≤ 50

Input Format For Custom Testing

  • The input consists of the number of students, n, followed by n student records where each record contains the fields: score, first_name, and last_name.

Sample Case 0

Input:

3  
Kye Lennon Roman  
Bates Hale Cabrera  

Function:

n = 3
first_name, last_name

Output:

Sorted student list according to the problem constraints.


  1. String XOR

Given a string s that consists of lowercase English letters, create a mapping M which assigns every lowercase letter (26 of them) to a distinct positive integer less than or equal to 100. Map the string to a series of integers where each letter is replaced by the integer it is mapped to. Formally, s = s₁s₂s₃...sₙ is now converted to the sequence M(s₁), M(s₂), M(s₃), ..., M(sₙ). Find a mapping M such that the bitwise XOR of all the numbers in the sequence is minimized.

For example, string s = "abc" and the mapping is M('a') = 65, M('b') = 66, M('c') = 3. The string s is now converted to 65, 66, 3. XOR these numbers together to get 0 which is the minimum. Other characters can be mapped to any other distinct numbers less than or equal to 100, so they are not shown here for convenience.

Function Description

Complete the function mapLettersToNumbers in the editor below. The function must return a vector that contains 26 distinct positive integers less than or equal to 100.

mapLettersToNumbers has the following parameter(s):

  • s: the given input string

Constraints

  • 1 ≤ |s| ≤ 10⁵
  • s consists only of lowercase English letters, ascii[a-z].

  1. User Transactions Count

A bank wants to know how many transactions were made by each of their customers in the years 2019, 2020, and 2021.

The first two characters of the transaction_id in the table transactions represent the year the transaction was made. For example, transaction_id 20345 would have been made in 2020. Write an SQL query that returns all the users and the number of transactions made by them in years 2019, 2020, and 2021 in different columns.

Note: The dataset also contains transactions from years other than these.

Table Definitions and Data Sample

There are 2 tables:

USERS

FieldType
user_idinteger
user_namestring

TRANSACTIONS

FieldType
transaction_idstring
user_idinteger

Write a query that joins these tables and counts transactions for each user in the specified years, grouping them by user_id and user_name.


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