Pick ONE option
You are implementing a call center software where customer calls are processed in the order they are received. The call center uses a circular queue to optimize memory usage.
Implement the function enqueue (call) in a circular queue.
Which of the following pseudocode correctly implements the enqueue operation for a circular queue?
Function initializeQueue (size) :
maxSize = size # Initialize Max Size
front = 0 # Initialize front pointer
rear = 0 # Initialize rear pointer
Your company is developing a file compression tool using Huffman encoding. You need to implement the function that builds the Huffman tree based on character frequencies.
Which of the following pseudocode correctly builds the Huffman tree?
Function buildHuffmanTree (frequencies) :
Create a priority queue Q
For each char in frequencies:
Insert char into with frequency as priority
While Q.size > 1:
left = Q. extractMin()
right = Q. extractMin()
newNode = Merge left and right
Insert newNode into l
Return Q. extractMin()
Pick ONE option
Pick ONE option
In TikTok's ecosystem, creators often form communities and collaborate within them. These relationships can be represented by a matrix related, where each cell related[i][] contains a binary value ('0' or 1). A '1' in related[i] means that Creator i and Creator j are directly connected, while a 'O' means they are not connected.
Creators can also be connected through indirect connections. For example, if Creator A is connected to Creator B and Creator B is connected to Creator C, then Creator A is indirectly connected to Creator C.
All creators that are connected, either directly or indirectly, form a distinct community. No two creators from different communities are connected to each other, either directly or indirectly.
Your task is to return the number of distinct creator communities based on the given relationship matrix related.
Function Description
Complete the function countCreatorCommunities in the editor below.
countCreatorCommunities has the following parameters):
string related[n]: An array of strings of binary digits relatedi] that represent the connection between creators.
Returns:
int: An integer that represents the number of distinct creator communities.
Constraints
• 15n ≤300
• Osien
• /related/ = n
• Each related[i] contains a binary string of n zeros and ones. related is a square matrix.
A TikTok developer is creating a method to give numbers to users, shown as an array arr.
The arrangement of numbers is called "good" if the difference between any two numbers next to each other is 1 or less. For example, the array [1, 2, 1] is good, but [2, 1, 3] is not, because the difference between 1 and 3 is 2, which is greater than 1.
The array arr has n numbers, but some numbers are missing. These
missing numbers are shown as arr[i = 0. The goal is to find how many ways
you can replace the missing numbers with any arbitrary integer numbers, so the final array is "good."
Since the number of ways can be very large, return the answer as the remainder when divided by (10^9 + 7).
Note: The array arr initially contains elements in the range
-10^9 ≤ arr[i] ≤ 10^9
. However, the indices with missing values (arr) = 0) can
be replaced with any arbitrary integer to make the final array "good."
Function Description
Complete the function countGoodArrays in the editor below.
countGoodArrays has the following parameter:
int arr[n]: an array of integers
Returns
int: the number of ways to replace missing elements to form a good array, modulo (109 + 7).
Constraints
• 1 ≤n≤ 1500
• -10^9 ≤ arr] ≤ 10^9
• There is at least one element in arrwhich is not equal to 0.