Example : {1,2,2,3,3}
the answer here is 5 :
{1,2,2} {1,2,3} {1,3,3} {2,2,3} {2,3,3}
I want a formula to calculate this.
I searched through Internet but I did not find a clear answer.
I am not good at math so I want a simple explination If that is possible. Thank you.
Helppppp Plssss
451E - Devu и цветы
https://cses.fi/book/book.pdf Page 72 (Of the book, not pdf) . Slightly change the algorithm and it should work
here is a beautiful solution from aops using generating functions. I don't know generating functions too much, but I understood the solution.