Tap here to switch tabs
Problem
Submissions

Problem: Valid Elements in an Array

Try to solve the Valid Elements in an Array problem.

Statement

You are given an integer array nums.

An element nums[i] is considered valid if it satisfies at least one of the following conditions:

  • It is the first element or the last element of the array.

  • nums[i] is strictly greater than every element to its left.

  • nums[i] is strictly greater than every element to its right.

Return an array containing all valid elements in the order they appear in nums.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Valid Elements in an Array

Try to solve the Valid Elements in an Array problem.

Statement

You are given an integer array nums.

An element nums[i] is considered valid if it satisfies at least one of the following conditions:

  • It is the first element or the last element of the array.

  • nums[i] is strictly greater than every element to its left.

  • nums[i] is strictly greater than every element to its right.

Return an array containing all valid elements in the order they appear in nums.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100