Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

Plz provide the solution asap in python or cpp . Plz it is a request Description Problem Statement You own a chocolate shop with chocolates

Plz provide the solution asap in python or cpp .Plz it is a request
Description
Problem Statement
You own a chocolate shop with chocolates priced from 1 to 109 consecutively. A student visits your shop for K consecutive days and buys chocolates indexed at (A1,A2,A3,....,An) on each day.
Formally, you are given an array 'A' representing the chocolate indexes the student buys each day. Your task is to determine the minimum-priced chocolate remaining in your shop after the Kth day.
Input format
The first line of input contains an integer N, denoting the indexes.
Next N lines contain an integer A[i] where A[1] A[2] A[3]q,K.
The next line contains an integer K, denoting the number of days.
Constraints
1N500
1A[i]109
1K105
Output format
Print the minimum-priced chocolate remaining in your shop after the Kth day.
Sample test cases
Input
5
1
2
4
5
6
1
Output
3
Explanation
1st day: 1st,2nd,4th,5th, and 6th chocolate is removed
{1,2,3,4,5,6,7,8dots........,109}.
So the chocolate set changes to {3,7,8,9,dotsdots...,109}.
Since K=1, the minimum price of chocolate left after the Kth day equals 3.
Input
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions