THE COMPARATOR FUNCTIONS RE QUITE DIFFICULT nd i have seen the video many a times , still im not able to understand. ND WHAT IS THE PAIR datatype.Also in Converttoint function when we did
ans+=((str[i]-‘0’)*p); ,what is str[i]-‘0’.
COMPARATOR FUNCTIONS, PAIR DATATYPE ,CONVERTOINT FUNCTION
Comparator functions is just a function that takes two parameter of the same type and returns a boolean. It is used to make custom sorting operations.
Open doubts regarding what you are not able to understand exactly , comparators is a broad term.
pair datatype is a pre define class in which u can group two datatypes together
say
pair<int ,float>
pair<int,string>
pair<string,string>
etc.
To reference them say we created pair<int,string> p=make_pair(5,“Hi”);
then cout<<p.first<<" "<<p.second; this will print 5 Hi
str[i] is a character and will give corresponding ascci value as int
and we subtract ‘0’ from it to make it int
i.e ‘0’-‘0’ gives 0
‘1’-‘0’ gives 1
and so on
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.