bhaiya i have commented in the code my problem
when i use the variable c for allocating memory it shows mle (. bad_alloc error ). but when i use some large number say2000 the code passes all the test cases. I unlocked all test cases all of them had the value of c<20000 so i used 20000 , it worked fine, but why it shows error with c
I have an issue with dyanamic allocation
hello @laksh.rustagi12
here (line 12) first check whether index is valid or not and then any other condition
bhaiya when I replace c with 20000 the same code passes all test cases
its because of line 12 only. make the changes and it will work with c as well
What to change in line 12 the logic Is correct ig
a) in line 12 , u need to make sure that index is valid and then other conditon
b) u have misinterprected the problem, we have n (the number of stall)
and c is the count of cows.
so ur array should be of size n to accomodate all stalls positions but u are making it of size c.
no bhaiya the array I have made is for storing the position of each cow
then check line 52…
han I got my mistake. I have been stuck for around 4-5 hours thinking my logic is wrong because I did not see the solution I tried it on my own