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.
// For this, before `while` loop, you need to initialize dynamic arrays (which are declared on top of the main) to store numbers of:// - total_number_of_books// - total_number_of_pages// x y : (a) Insert a book (b) with y pages (c) at the end of the x^th shelf.// (a) Insert a booktotal_number_of_books[x]+=1;// *(total_number_of_books + x) += 1; // the same - equivalent in old books/tutorials// (b) allocate memory (int) for the new shelf: ( void *ptr, size_t new_size );// - total_number_of_pages just get bigger by int as we inserted a book// (c) assign number of pages [y] to the x^th shelf
Simpler, isn't it?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dynamic Array in C
You are viewing a single comment's thread. Return to all comments →
The problem is not clear about implementation.
Here is my explanation.
Simpler, isn't it?