New update is available. Click here to update.

Problem title
Difficulty
Avg time to solve

Maximum Subarray Sum
Hard
35 mins
Flower Shop
Easy
--
Swap Two Numbers
Easy
10 mins
Find Unique
Easy
--
Beautiful String
Easy
18 mins
Duplicate In Array
Easy
15 mins
Yogesh And Primes
Moderate
20 mins
First Missing Positive
Moderate
18 mins
First and Last Position of an Element In Sorted Array
Easy
15 mins

Flower Shop

Easy
Share
492 upvotes

Problem Statement

Oasis visits a Florist Shop. Shop has N flowers each being of a specific type and every flower costs 1 unit.

You are given type of each flower in an array P = [p1,p2,...,pN]. If he buys a flower of type P’ , then he will get all flowers whose type lies between P’ to P’+4 (both inclusive) for free.

You need to find and print the price Oasis has to pay to buy all flowers.

Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input
5
1 2 3 17 10
Sample Output
3
Reset Code
Full screen
copy-code
Console