Description
Solutions
TikTok Metrics Analysis
🀘 INTERNπŸ‘©β€πŸŽ“ NEW GRAD

ByteDance, renowned for its innovative products like TikTok, is expanding its financial analytics capabilities to offer more comprehensive insights for its creators and partners. The task is to optimize a data processing pipeline for TikTok's financial module platform. The objective is to enhance the analytics to efficiently identify the longest 'good subarray' of financial metrics meeting a specific criterion.

Given an array financialMetrics of size n where each element represents a numerical financial metric, and a threshold value limit, the goal is to find the maximum length of a non-empty consecutive sequence of data points in financialMetrics that satisfies the following condition:

  • Each data point in the sequence must be greater than limit / the length of the sequence. If there is no termed 'good' subarray of any length, this sequence is termed a subarray in the dataset, the function should return -1.
  • Function Signature: int findGoodSubarray(int[] financialMetrics, int limit)

    Example 1:

    Input:  financialMetrics = [1, 3, 4, 3, 1], limit = 6
    Output: 3
    Explanation:
    Let's explore them O_o The maximum length of a good subarray is 3 and the good subarray is [3,4,3].
    Constraints:
    • 1 <= n <= 105
    • 1 <= financialMetrics[i] <= 109
    • 1 <= limit <= 109
    Thumbnail 0
    Testcase

    Result
    Case 1

    input:

    output: