0

I wanted to remove the occurrence of an element from array if it occurs more than n times... For example-
{ 20, 37, 20, 21 } (n->1) -----> { 20, 37, 21}
{ 1, 1, 1, 1, 1 } (n->5) -----> { 1, 1, 1, 1, 1 }
{ 1, 2, 3, 1, 1, 2, 1, 2, 3, 3, 2, 4, 5, 3, 1 } (n->3 ) --------> { 1, 2, 3, 1, 1, 2, 2, 3, ...