specifying vector size at compile time

  • 0

    I had seen sometime u can use vector without specifying its size but sometime u will get runtime error and u r forced to specify the size. I think this issue is related to vector failing to allocate more memory if size is not specified. Anybody has clear idea what actually happens ?

    vector<vector<int>>result; --->fails

    vector<vector<int>>result(r,vector<int>(c,0)); -->passes

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.