Dynamic Array in C (C Language series of hacker rank) :
Pooja Pedgaonkar
IT Engineer | Software development ?? | Full stack web development ???? | Data Science Enthusiast ??
Whenever a dynamic word comes, the malloc function is mostly used for memory allocation, and pointers are used because pointers play a vital role in dynamic memory allocation. There is a medium-level question of hacker rank which covers dynamic arrays in C. In this question, we are using the double pointer concept. It might be confusing for the first time but trust me it is a very easy question if you understood the concept of pointers.
This is the best question for understanding the concept of the pointer provided by hacker rank.
Problem Statement :
Snow Howler is the librarian at the central library of the city of HuskyLand. He must handle requests which come in the following forms:
1 x y: Insert a book with?’y’?pages at the end of the?’xth’?shelf.
2 x y: Print the number of pages in the?’yth’?book on the?’xth’?shelf.
3 x: Print the number of books on the?’xthDynamic Array in C (C Language series of hacker rank) :?’?shelf.
Snow Howler has got an assistant, Oshie, provided by the Department of Education. Although inexperienced, Oshie can handle all of the queries of types?2?and?3.
Help Snow Howler deal with all the queries of type?1.
Oshie has used two arrays:
Input Format :
The first line contains an integer total_number_of_shelves, the number of shelves in the library.
The second line contains an integer total_number_of_queries, the number of requests.
Each of the following total_number_of_queries lines contains a request in one of the three specified formats.
Link in the comments ???? ???? ????
Follow?Pooja Pedgaonkar?for?#learning?and?#coding
Awesome job on breaking down dynamic arrays in C! That breakdown was super easy to follow. You should totally look into data structures next, it'll blow your mind how they work with what you've already learned. What part of programming do you see yourself diving into in the future?
IT Engineer | Software development ?? | Full stack web development ???? | Data Science Enthusiast ??
2 年Here is the link to the problem statement : https://www.hackerrank.com/challenges/dynamic-array-in-c/problem I am going to provide a link to the solution to the above problem, please go through it. https://github.com/Pooja7720/HackerRank/blob/main/C%20Language/Dynamic%20Array%20in%20C