nums
의 길이까지 순회nums
의 모든 요소 순회nums
의 요소중 현재 수 이상의 수가 동일한지 확인function specialArray(nums: number[]): number {
const n = nums.length
let max = -1
for(let i = 1; i <= n; i++) {
let count = 0
for(let j = 0; j < n; j++) {
const cur = nums[j]
if(cur >= i) count++
}
if(i !== count) continue
max = i
}
return max
};