We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You don't have to allocate memory for the query. Each query is a read, use and discard thing as you have it.
However, your for loops are bad. The conditions you have will cause accesses past the end of the arrays and other symptoms. For example the row reading loop will generate accesses to a[0] through to a[n]. That is n+1 items. Your allocation is for only n items though.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
You don't have to allocate memory for the query. Each query is a read, use and discard thing as you have it.
However, your for loops are bad. The conditions you have will cause accesses past the end of the arrays and other symptoms. For example the row reading loop will generate accesses to a[0] through to a[n]. That is n+1 items. Your allocation is for only n items though.