Abhinav and his friends
Lesson 11 of 11 in Coddy's Bubble Sort course.
Challenge
MediumAbhinav wants to gift books to his friends on friends day. He has k friends so he has to buy k books. He visited a book store, there was n books in the store . You are provided with an array of n numbers, each elements denotes the price of a book. Ai denotes price of ith book. Abhinav is very stingy , he want to gift k cheapest books to his friends. Help him to find the minimum amount of money he has to spent to buy k books.
Create a function named k_books that receives an array, length of the array (n) and an integer k (k<=n). Return minimum amount of money Abhinav has to spent to buy k books.
Try it yourself
#include <stdio.h>
#include <stdlib.h>
int k_books(int* arr, int arr_size, int n, int k) {
// Write code here
return 0;
}
All lessons in Bubble Sort
1Basics of Bubble Sort
IntroductionWorking of the Bubble SortSwap adjacent elementsBubble Sort Algorithm