Problem · Array

TikTok Metrics Analysis

Learn this problem
MediumTiktokINTERNNEW GRADOA
See Tiktok hiring insights

Problem statement

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)

    Function

    findGoodSubarray(financialMetrics: int[], limit: int) → int

    Examples

    Example 1

    financialMetrics = [1, 3, 4, 3, 1]limit = 6return = 3
    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

  • 1 <= n <= 105
  • 1 <= financialMetrics[i] <= 109
  • 1 <= limit <= 109
  • More Tiktok problems

    drafts saved locally
    public int findGoodSubarray(int[] financialMetrics, int limit) {
      // write your code here
    }
    
    financialMetrics[1, 3, 4, 3, 1]
    limit6
    expected3
    checking account