Subsequences of Three

Problem Overview

  • Determine the array's validity by checking every 3-element subsequence S and taking min of 3*abs(mean(S) - median(S)).
  • Input: arr[n] of distinct integers (3 <= n <= 10^3, 1 <= arr[i] <= 10^9); Output: an integer validity.
  • Subsequence preserves order; mean is average; median is the middle of three.
  • From Tiktok interviews; a coding interview problem and interview question in the array/statistics domain.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: