Tap here to switch tabs
Problem
Submissions

Problem: Check if Array is Good

med
30 min
Try to solve the Check if Array is Good problem.

Statement

You are given an integer array nums.

An array is considered good if it is a permutation of an array base[n], defined as base[n] = [$1$, $2$, ..., $n - 1$, $n$, $n$] for some positive integer nn.

In other words, base[n] has a length of n+1n + 1 and contains each integer from 11 to n−1n - 1 exactly once, with the integer nn appearing exactly twice.

Return true if nums is a good array, or false otherwise.

Note: A permutation of an array is an arrangement of its elements in any order.

Constraints:

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Array is Good

med
30 min
Try to solve the Check if Array is Good problem.

Statement

You are given an integer array nums.

An array is considered good if it is a permutation of an array base[n], defined as base[n] = [$1$, $2$, ..., $n - 1$, $n$, $n$] for some positive integer nn.

In other words, base[n] has a length of n+1n + 1 and contains each integer from 11 to n−1n - 1 exactly once, with the integer nn appearing exactly twice.

Return true if nums is a good array, or false otherwise.

Note: A permutation of an array is an arrangement of its elements in any order.

Constraints:

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

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