Https://practice.geeksforgeeks.org/problems/geeks-and-groceries/0/#

hello @vashishthkuntal.gajjar2019

read the problem statement once again.

I read that is why I am asking

a)
then why u are taking input as char?

u are given n lines and in each line first u have string and then its price. u will need pair of string and int for that to stpre each gorcery info
b) also their is no point of sorting the char array, u need to sort based on price and for that u need to write a custom comparator that will take pair and order them based on price.

u shuld know about strings, array , sorting ,custom comparators ,pairs to sove this problem.

but can’t we do by using only strings as number can also be taken as in input?

no, sorting of number is done on the basis of magnitude and sign whereas in string its lexigraphical based.

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.