Beautiful Vertices Problem

All test cases giving WA.
link : https://ide.codingblocks.com/s/234139

Please help

@shubhamhalder0
Hey buddy
Your approach seems fine
Must be something small that I’m missing
So please cross verify your solution with this

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.