Given an integer array nums where each element is either a positive integer or
You start with an empty array seen and an empty array ans. You iterate through nums from left to right:
If the current element is positive, prepend it to the front of seen and reset the count of consecutive
If the current element is k.
If k is less than or equal to the length of seen, append the seen to ans.
Otherwise, if k is strictly greater than the length of seen, append ans.
Return the array ans.
Constraints:
nums.length
nums[i] nums[i]
Given an integer array nums where each element is either a positive integer or
You start with an empty array seen and an empty array ans. You iterate through nums from left to right:
If the current element is positive, prepend it to the front of seen and reset the count of consecutive
If the current element is k.
If k is less than or equal to the length of seen, append the seen to ans.
Otherwise, if k is strictly greater than the length of seen, append ans.
Return the array ans.
Constraints:
nums.length
nums[i] nums[i]