ans vector contains each number only up to occ times. So, occ can never be negative. If user passed a negative number as occ, then ans vector will be empty.
ans
occ
If given numbers are negative, still there should not be any problem. Example,
delete_nth({-1,-1,-1,-2,-3,-2,-4,-3}, 1) => {-1,-2,-3,-4} delete_nth({1,-2,3,-7,-2,3,-8},1) => {1,-2,3,-7,-8}
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
ans
vector contains each number only up toocc
times. So,occ
can never be negative. If user passed a negative number asocc
, thenans
vector will be empty.If given numbers are negative, still there should not be any problem. Example,