Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6379
@blackshadows 6329
@mb1973 5358
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Check if array contains contiguous integers with duplicates allowed
Easy Accuracy: 84.01% Submissions: 193 Points: 2

Given an array of n integers(duplicates allowed). Print “Yes” if it is a set of contiguous integers else print “No”.

Example 1:

​Input : arr[ ] = {5, 2, 3, 6, 4, 4, 6, 6}
Output : Yes
Explanation:
The elements  of array form a contiguous 
set of integers which is {2, 3, 4, 5, 6} 
so the output is "Yes".


Example 2:

Input : arr[ ] = {10, 14, 10, 12, 12, 
                              13, 15} 
Output : No



Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function areElementsContiguous() that takes an array (arr), sizeOfArray (n), and return the true if it is a set of contiguous integers else print false. The driver code takes care of the printing.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).


 

CONSTRAINTS:
1 ≤ N ≤105
1 ≤ a[i] ≤ 105

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Check if array contains contiguous integers with duplicates allowed

Output Window