Help required with cause of runtime error

Hello.
I get the below error when attempting to run the modified solution code I wrote on LeetCode

Error:
Line 1034: Char 9: runtime error: reference binding to null pointer of type ‘int’ (stl_vector.h)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/…/lib/gcc/x86_64-linux-gnu/9/…/…/…/…/include/c++/9/bits/stl_vector.h:1043:9

I’m unable to locate the reason for this error.

Code Link: https://ide.codingblocks.com/s/386336

Hey @sabihash
Please share the link to the question

Hello, Link to question is at https://online.codingblocks.com/app/player/174625/content/172189/8506/code-challenge

Oh u are getting this error on Coding blocks platform?

Now try to debug logically

         for(int i=0;i<numCourses;i++){
            indegree.push_back(0);   //changed this because indegree[i] is not allocated 
            edgeList[i]=vector<int>();
         }

Thank you! It seems I missed that somehow.

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.