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.
I also went with a similar implementation and it was accepted. However, it looked suspicious to me because the statement:
int *array[N] should not be allowed. That N variable should not be allowed -- it MUST BE CONSTANT.
I double checked and entered this code into visual studio and indeed get a compiler error C2131 "Expression did not evaluate to a constant."
I think the correct implementation is two declare a 2D array of points and initialize each dimension dynamically like some other users described:
int** seq=new int* [n];
PS I agree with all the other comments left below regarding free and delete.
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 →
I also went with a similar implementation and it was accepted. However, it looked suspicious to me because the statement: int *array[N] should not be allowed. That N variable should not be allowed -- it MUST BE CONSTANT.
I double checked and entered this code into visual studio and indeed get a compiler error C2131 "Expression did not evaluate to a constant."
I think the correct implementation is two declare a 2D array of points and initialize each dimension dynamically like some other users described: int** seq=new int* [n];
PS I agree with all the other comments left below regarding free and delete.