Back to February Back to Year 2026
EASY 03 Feb 2026 View on LeetCode

3637. Trionic Array I

</> Solution

/**
 * Problem: LeetCode 3637 - Trionic Array I
 * Difficulty: Easy
 * Language: Java
 * Author: CodeByTushu
 */
class Solution {
    public boolean isTrionic(int[] nums) {
        int n = nums.length;
        if (n < 4) {
            return false;
        }

        int i = 0;

        // Phase 1: Strictly increasing to peak p
        while (i + 1 < n && nums[i] < nums[i + 1]) {
            i++;
        }
        int p = i;
        if (p == 0 || p >= n - 2) {
            return false;
        }

        // Phase 2: Strictly decreasing to valley q
        while (i + 1 < n && nums[i] > nums[i + 1]) {
            i++;
        }
        int q = i;
        if (q == p || q >= n - 1) {
            return false;
        }

        // Phase 3: Strictly increasing to the end
        while (i + 1 < n && nums[i] < nums[i + 1]) {
            i++;
        }

        return i == n - 1;
    }
}

TIME COMPLEXITY

O(N)

SPACE COMPLEXITY

O(1)

TOPICS

Array Simulation Two Pointers