Three-Level Signal Pattern
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Three-Level Signal Pattern
A signal audit is suspicious when three readings form a low-high-middle pattern in their original order. Specifically, there must be indices i, j, and k such that i < j < k and nums[i] < nums[k] < nums[j]. The selected values do not need to be adjacent. Only their order in the array matters. Input Format: You are given an integer array nums. Output Format: Return true if a three-level signal pattern exists, otherwise return false.
Examples
Example 1
Input:
nums = [1, 2, 3, 4]
Output:
NO
Explanation: No three indices i < j < k satisfy nums[i] < nums[k] < nums[j], so the output is NO.
Approach hint
Scan from the right.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp