Please tell me how to approach to this

i checked GFG but they use graph ,hashmap, vector ,
but we did not covered thish till now ,

please hepl me through this

hi @mahroosanwar0901_2642b14836027bbf
since u have not studied graphs, hashmap u can refer the straight forward method at gfg.
its complexity is not that good (O(n*n)), for now u can go through it…
rest vector and array are same only, just a little different writing convention… where ever there is vector used u can replace it with array… but if study a little bit of vectors, then its much more convenient than arrays…

@mahroosanwar0901_2642b14836027bbf
Is there anything else??

hey I try to understand that gfg code you mentio but i did not understand fully because of vector, can you make a code that replace the vactor to array and mention some comment please


refer this… I have replaced vector with array…

thanks you can mark as resolve

1 Like

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.