FastPrepFastPrep
Problem Brief

TikTok Metrics Analysis

INTERNNEW GRADOA
See Tiktok online assessment and hiring insights

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)

    1Example 1

    Input
    financialMetrics = [1, 3, 4, 3, 1], limit = 6
    Output
    3
    Explanation
    Example 1 illustration
    Let's explore them O_o The maximum length of a good subarray is 3 and the good subarray is [3,4,3].

    Constraints

    Limits and guarantees your solution can rely on.

  • 1 <= n <= 105
  • 1 <= financialMetrics[i] <= 109
  • 1 <= limit <= 109
  • public int findGoodSubarray(int[] financialMetrics, int limit) {
      // write your code here
    }
    
    Input

    financialMetrics

    [1, 3, 4, 3, 1]

    limit

    6

    Output

    3

    Sign in to submit your solution.