//
https://www.hackerrank.com/challenges/variable-sized-arrays //original challenge
//How should I avoid memory leak ,just delete the pointers declared by new keyword ?
//Any better hint for this challenge ? instead of using int *p = new int strategy
//I can't use vector here ,because the requirements
@kbw Thanks ,My own class idea is good ,but it's harder than simply implementing the code in main ,besides the algorithm ,I have to think about parameters and the access privilege and so many things ,
@dhayden ,Thank you , I managed to find many bugs including this one you mentioned this morning ,I think I got lost when coding yesterday .
*update:
my code was so buggy ,so I deleted it ,I can't stand it so I start writing new one now
my question is : is there any way other than using new keyword can build a variable sized array ?
There are only two ways coming to my mind now :
1.vector which is not allowed
2.using new keyword to allocate raw memory ,which is prone to bugs I guess.
3.What about the third way ?
4. Can someone here demonstrate a sample solution to this challenge ?